How To Add Tap Listener On Data Point?
I want to a add tap listener on a data point in the graph view in Android Studio. There is a problem in my java code that says: can't resolve method get Activity() in last line of
Solution 1:
Your OnDataPointTapListener
is an anonymous class, inside this class the method getActivity
does not exist, but it does exits within your Activity. You should use the this
from your MainActivity
not this from your OnDataPointTapListener
:
Toast.makeText(MainActivity.this.getActivity(), "Series1: On Data Point clicked: "+dataPoint, Toast.LENGTH_SHORT).show();
Solution 2:
Instead of getActivity put MainActivity.this
Toast.makeText(MainActivity.this, "Series1: On Data Point clicked: "+dataPoint, Toast.LENGTH_SHORT).show();
Post a Comment for "How To Add Tap Listener On Data Point?"