0

我似乎遇到了 achartengine 的问题。当我在扩展 Fragment 的类中使用 appendData 时,出现此错误:

07-29 19:43:17.742: W/dalvikvm(12504): VFY: unable to resolve static method 4458: Ljava/util/Arrays;.copyOf ([Ljava/lang/Object;I)[Ljava/lang/Object;
07-29 19:43:21.752: W/dalvikvm(12504): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
07-29 19:43:21.752: E/AndroidRuntime(12504): FATAL EXCEPTION: main
07-29 19:43:21.752: E/AndroidRuntime(12504): java.lang.NoSuchMethodError: java.util.Arrays.copyOf
07-29 19:43:21.752: E/AndroidRuntime(12504):    at com.jjoe64.graphview.GraphViewSeries.appendData(GraphViewSeries.java:64)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at com.multiwii.multiwiiremote.MyFragment$1.run(MyFragment.java:150)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at android.os.Handler.handleCallback(Handler.java:587)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at android.os.Looper.loop(Looper.java:123)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at android.app.ActivityThread.main(ActivityThread.java:4627)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at java.lang.reflect.Method.invokeNative(Native Method)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at java.lang.reflect.Method.invoke(Method.java:521)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
07-29 19:43:21.752: E/AndroidRuntime(12504):    at dalvik.system.NativeStart.main(Native Method)

我不确定错误消息告诉我什么?如果我不更新图表,它会显示得很好。这是我用作参考的示例: https ://github.com/jjoe64/GraphView-Demos/blob/master/src/com/jjoe64/graphviewdemos/RealtimeGraph.java

这是我的代码:

public class MyFragment extends Fragment implements SensorEventListener {
    int mCurrentPage;
    View myV = null;
    LinearLayout layout;
    GraphView graph;
    GraphViewSeries graphViewSeries;
    private double graph2LastXValue = 3d;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        /** Getting the arguments to the Bundle object */
        Bundle data = getArguments();

        /** Getting integer data of the key current_page from the bundle */
        mCurrentPage = data.getInt("current_page", 0);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        switch (mCurrentPage) {
        case 0:
            break;
        case 1:
            myV = inflater.inflate(R.layout.graph, container, false);
            layout = (LinearLayout) myV.findViewById(R.id.graph_layout);
            graphViewSeries = new GraphViewSeries(new GraphViewData[] { new GraphViewData(1, 2.0d), new GraphViewData(2, 10.0d) });
            graph = new LineGraphView(getActivity(), "Test");
            graph.addSeries(graphViewSeries);
            layout.addView(graph);
            myHandler.postDelayed(Hello, 4000);
            break;
        case 2:
            break;
        }
        return myV;
    }

    private double getRandom() {
       double high = 3;
       double low = 0.5;
       return Math.random() * (high - low) + low;
    }

Handler myHandler = new Handler();
Runnable Hello = new Runnable() {

   public void run() {
        if(mCurrentPage == 1) {
            graph2LastXValue += 1d;
            graphViewSeries.appendData(new GraphViewData(graph2LastXValue, getRandom()), true); //It crashes here
        }
        myHandler.postDelayed(this, 1000);
    }

};

    OnHeadlineSelectedListener mCallback;

    public interface OnHeadlineSelectedListener {

    }
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        try {
            mCallback = (OnHeadlineSelectedListener) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + " must implement OnHeadlineSelectedListener");
        }
    }

}

关于错误消息的含义以及如何解决它的任何想法?

谢谢

4

1 回答 1

0

你有最新版本的库吗?由于这里 github.com/jjoe64/GraphView/blob/master/src/com/jjoe64/... 在第 70 行它不使用 Arrays.copyOf() 静态方法吗?

于 2013-07-30T01:37:59.237 回答