Reputation: 117
I am using MPAndroidChart library.
I have used Horizontal bar charts in my dashboard.
I want to navigate to another activity by clicking particular bar of that chart.
How can i do this??
Upvotes: 6
Views: 3406
Reputation: 51421
That's actually pretty easy, all you have to do is use the OnChartValueSelectedListener
and start your new Activity
from the callback methods.
You can find an example of how that works here.
Basically, implement the listener in your class that holds the chart:
public class SomeClass implements OnChartValueSelectedListener {
Set the listener to the chart:
chart.setOnChartValueSelectedListener(this);
Start your new activity in the callback:
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
// start new activity
}
Upvotes: 7