我试图访问屏幕坐标相对于我用来绘制图形的值。但是现在我试图在XYChart类中使用toSreeenPoint方法来协调访问。 这是我正在使用的代码,
if (layout != null) {
layout.removeAllViews();
mChartView = ChartFactory.getCubeLineChartView(MyActivity.this, dataset, multiRenderer, 0.33f);
layout.addView(mChartView);
// mChartView = null;
mChartView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
SeriesSelection ss = mChartView.getCurrentSeriesAndPoint();
XYChart chart = new LineChart(dataset, multiRenderer);
XYSeries series = dataset.getSeriesAt(0);
if(chart != null) {
for(int i = 0; i < series.getItemCount(); i++) {
Log.d(TAG, "Serieous COunt"+series.getX(i));
Log.d(TAG, "Serieous COunt#1"+series.getY(i));
Log.d(TAG, "Type is"+chart.getChartType());
double[] xy = chart.toScreenPoint(new double[]{series.getX(i), series.getY(i)});
//Log.d(TAG, "Check is right" + chart.getSeriesAndPointForScreenCoordinate(new Point((float) xy[0], (float) xy[1])));
}
} else {
Log.d(TAG, "Check is Wrong");
}
return false;
}
});
}
但是有些原因它在chart.toScreenPoint行上崩溃了NULL POint Exception。我检查使用longs没有什么是null直到该行。请帮助找到我做错的事情......