正の値と負の値の両方を含むファイル(.csv)から値を読み取る必要があります。文字列を整数に変換中にエラーが発生します。
Scanner sc = new Scanner(getAssets().open("Book1.csv")).useDelimiter(",");
int i = 0;
while (sc.hasNext()) {
String str = sc.next();
data[i] = new GraphViewData(i, Integer.parseInt(str));
i++;
}
以下は私のlogcatです:
05-02 04:05:55.119: E/AndroidRuntime(3003): ' as integer
05-02 04:05:55.119: E/AndroidRuntime(3003): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-02 04:05:55.119: E/AndroidRuntime(3003): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-02 04:05:55.119: E/AndroidRuntime(3003): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-02 04:05:55.119: E/AndroidRuntime(3003): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-02 04:05:55.119: E/AndroidRuntime(3003): at android.os.Handler.dispatchMessage(Handler.java:99)
05-02 04:05:55.119: E/AndroidRuntime(3003): at android.os.Looper.loop(Looper.java:123)
05-02 04:05:55.119: E/AndroidRuntime(3003): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-02 04:05:55.119: E/AndroidRuntime(3003): at java.lang.reflect.Method.invokeNative(Native Method)
05-02 04:05:55.119: E/AndroidRuntime(3003): at java.lang.reflect.Method.invoke(Method.java:507)
05-02 04:05:55.119: E/AndroidRuntime(3003): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-02 04:05:55.119: E/AndroidRuntime(3003): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-02 04:05:55.119: E/AndroidRuntime(3003): at dalvik.system.NativeStart.main(Native Method)
05-02 04:05:55.119: E/AndroidRuntime(3003): Caused by: java.lang.NumberFormatException: unable to parse '893