【问题标题】:Android - Achartengine XYScatter OnclickListenerAndroid - Achartengine XYScatter OnclickListener
【发布时间】:2012-10-12 23:15:49
【问题描述】:

我在让 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 有关吗?

我尝试搜索多个网站均无济于事。 Example

【问题讨论】:

  • 编辑:好的,我发现了这个问题。所以我在图表中有多个系列,有时系列是空白的。由于某种原因,当它们为空白时,整个图表将不允许您选择点。如果有人有解决方案,我会接受建议。我想我将只添加一个检查以查看该系列是否应该添加到多个渲染器中。我不确定我是否应该删除这篇文章,但会暂时保留它,以防其他人遇到此问题。

标签: android achartengine


【解决方案1】:

如果有人有兴趣查看更多执行此操作的示例,我建议查看官方 AChartEngine 演示代码,尤其是与您的问题相关的 this 示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-20
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-13
    相关资源
    最近更新 更多