我在让 onclicklistener 与 achartengine1.0.0 for android 一起工作时遇到问题。具体来说,我无法从“.getCurrentSeriesAndPoint”(始终为空)返回任何内容。
SeriesSelection seriesSelection = gView.getCurrentSeriesAndPoint();
所以我有一个类创建我的图 TableView 如下...
public class xyScatter extends Application {
public GraphicalView getGView(Context context) {
...(STUFF)...
mRenderer.setClickEnabled(true);
mRenderer.setSelectableBuffer(100);
...(STUFF)...
return ChartFactory.getScatterChartView(context, dataset, mRenderer);
}
}
然后在我的 Activity 中我有以下方法
private void displayXY() {
xyScatter xyScat = new xyScatter();
final GraphicalView gView = xyScat.getGView(this);
glayout.removeAllViews();
glayout.addView(gView);
gView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SeriesSelection seriesSelection = gView.getCurrentSeriesAndPoint();
Log.d("seriesSelection", String.valueOf(seriesSelection));
if (seriesSelection == null) {
Log.d("OnClickXY", "Nothing Selected");
} else {
Log.d("OnClickXY", "Something Selected");
}
}
});
}
这与我在 linearLayout 中将图表添加为 GraphicalView 有什么关系吗?
我尝试搜索了多个站点,但都无济于事。 Example
最佳答案
如果有人有兴趣查看更多这样做的示例,我建议查看官方 AChartEngine 演示代码,尤其是在 this。与您的问题相关的示例。
关于安卓-Achartengine XYScatter OnclickListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12868349/