1
我正在實施MP安卓條形圖。在我點擊條形圖時,需要顯示兩個圖表,表示單擊和其他雙擊時的一個圖形。 請幫幫我。如何在雙擊安卓手機圖表中獲取價值
我正在實施MP安卓條形圖。在我點擊條形圖時,需要顯示兩個圖表,表示單擊和其他雙擊時的一個圖形。 請幫幫我。如何在雙擊安卓手機圖表中獲取價值
有一個接口OnChartGestureListener
,其中包含了兩個方便的方法:
void onChartDoubleTapped(MotionEvent me)
void onChartSingleTapped(MotionEvent me)
他們的名字爲自己說話。剛上Chart
調用適當的方法:
public void setOnChartGestureListener(OnChartGestureListener l)
例子:
mChart.setOnChartGestureListener(new OnChartGestureListener() {
@Override
public void onChartDoubleTapped(MotionEvent me) {
Toast.makeText(MainActivity.this, "Double", Toast.LENGTH_SHORT).show();
}
@Override
public void onChartSingleTapped(MotionEvent me) {
Toast.makeText(MainActivity.this, "Single", Toast.LENGTH_SHORT).show();
}
});
爲參數你MotionEvent
。
要獲得X和Y值,請撥打:
mChart.getHighlightByTouchPoint(me.getX(), me.getY()).getX();
mChart.getHighlightByTouchPoint(me.getX(), me.getY()).getY()
它應該BarChart
工作。還記得禁用變焦上雙擊:
mChart.setDoubleTapToZoomEnabled(false);
然而,它可能無法正常工作,因爲我已經看到了PieChart
這是行不通的。只有長按和單按才能使用它。