###前提・実現したいこと
テキストデータから読み込んだ数値をスマホ上に表示したい.
どこにeditTextを入れるのが適切なのでしょうか?
読み込んだデータ例
1 2 3
4 5 6
7 8 9
###発生している問題・エラーメッセージ
エミュレータにactivity has stopped
###該当のソースコード
@Override protected void onResume() { super.onResume(); // 使用するセンサーの設定 Sensor acceleration = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); // センサーを有効にする mSensorManager.registerListener(this, acceleration, SensorManager.SENSOR_DELAY_NORMAL); try { try { // assetsフォルダ内の sample.txt をオープンする is = this.getAssets().open("sample.txt"); br = new BufferedReader(new InputStreamReader(is)); String str; str = br.readLine(); while(str != null){ splitted = str.split(" "); for (xyz=0; xyz<3; xyz++) { Index[count][i] = Integer.parseInt(splitted[xyz]); } } br.close(); } finally { if (is != null) is.close(); if (br != null) br.close(); } } catch (Exception e){ // エラー発生時の処理 } editText.setText(splitted[1]); }
###試したこと
edittextウィンドウを作り、catch文の後に配列の1つを表示するようにしました
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/21 18:09