2013-07-30 92 views
0

我似乎對achartengine有問題。當我在擴展片段一類使用appendData,我得到這個錯誤:AChartEngine Android - 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"); 
     } 
    } 

} 

什麼錯誤消息的含義以及如何解決它的任何想法?

謝謝

+1

你有最新版本的圖書館嗎?由於第70行的https://github.com/jjoe64/GraphView/blob/master/src/com/jjoe64/graphview/GraphViewSeries.java,它不使用'Arrays.copyOf()'靜態方法? –

+0

不,我從舊的下載鏈接使用3.0。新版本就像一個魅力:)。發表您的評論作爲答案,我會接受它。 – user2632173

+0

這不是AChartEngine相關的問題。 –

回答

0

您是否擁有該圖書館的最新版本?從這裏github.com/jjoe64/GraphView/blob/master/src/com/jjoe64/...在線70它不使用Arrays.copyOf()靜態方法?