我在让 onclicklistener 与 achartengine1.0.0 for android 一起工作时遇到问题。具体来说,我无法从“.getCurrentSeriesAndPoint”(始终为空)返回任何内容。
SeriesSelection seriesSelection = gView.getCurrentSeriesAndPoint();
所以我有一个类来创建我的图表视图,如下所示......
public class xyScatter extends Application {
public GraphicalView getGView(Context context) {
...(STUFF)...
mRenderer.setClickEnabled(true);
mRenderer.setSelectableBuffer(100);
...(STUFF)...
return ChartFactory.getScatterChartView(context, dataset, mRenderer);
}
}
然后在我的活动中,我有以下方法
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");
}
}
});
}
这与我在线性布局中将图表添加为 GraphicalView 有关吗?
我尝试搜索了几个网站均无济于事。例子