多次点击图表视图会导致应用程序崩溃

时间:2014-10-11 08:16:30

标签: android crash onclicklistener

我正在使用图表视图显示结果视图。如果我在图表视图上多次单击,则应用程序崩溃。如何防止用户在图表视图上多次点击。

private View getSpeedChartView(final FtpResult result, final boolean isDownload, final boolean useMbps) {
    AbstractChart chart = getSpeedChart(result, isDownload, useMbps,
        createXYMultipleSeriesRenderer(isDownload, useMbps, false));
    if (chart == null) {
        return null;
    }

    View view = new GraphicalView(mActivity, chart);
    view.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mActivity.startActivity(new Intent(mActivity, GraphicalActivity.class)
                .putExtra(ChartFactory.CHART,
                    getSpeedChart(result, isDownload, useMbps,
                        createXYMultipleSeriesRenderer(
                            isDownload, useMbps, true)))
                .putExtra(ChartFactory.TITLE, (String) null));
        }
    });
    return view;
}

private AbstractChart getSpeedChart(FtpResult result, boolean isDownload,
        boolean useMbps, XYMultipleSeriesRenderer renderer) {
    if (mConfig.iterations == 1) {
        return result.iterations.size() > 0 ?
                getSpeedTimeChart(result.iterations.get(0),
                        isDownload, useMbps, renderer) : null;
    }
}

这是我的堆栈跟踪报告:

STACK_TRACE=java.lang.NullPointerException
at org.achartengine.chart.XYChart.toRealPoint(XYChart.java:805)
at org.achartengine.tools.Pan.apply(Pan.java:74)
at org.achartengine.TouchHandler.handleTouch(TouchHandler.java:126)
at org.achartengine.GraphicalView.onTouchEvent(GraphicalView.java:286)
at android.view.View.dispatchTouchEvent(View.java:7143)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1949)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1938)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1392)
at android.app.Activity.dispatchTouchEvent(Activity.java:2408)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1886)
at android.view.View.dispatchPointerEvent(View.java:7323)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3560)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3490)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4637)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4597)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4749)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:125)
at android.os.Looper.loop(Looper.java:140)
at android.app.ActivityThread.main(ActivityThread.java:5000)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

升级到我的程序中的新jar文件。现在没有问题。

链接是访问(https://code.google.com/p/achartengine/downloads/list)!