-1

ユーザーがデータを入力して表示できる時刻表アプリを作成しました。ただし、ユーザーがエントリを入力すると、既にエントリがある日時に、エミュレータがクラッシュします (強制的に終了します)。基本的に、データを線形レイアウトに戻しています。これには、それぞれが 9 ~ 15 の時間を表す 10 個の TextView が含まれています。コードは次のとおりです。

        public void addMondayGrid() {
    // TODO Auto-generated method stub
    for (int index = 0; index < info.mon.size(); index++) {

        // int entryId = info.monIds.get(index);
        int time = info.monTimes.get(index);
        int id = info.monIds.get(index);
        int duration = info.monDuration.get(index);
        String dayOfWeek = "mon";

        timeId = getResources().getIdentifier("mon" + time, "id",
                getPackageName());
        if (duration == 1) {
            SpannableString text = new    SpannableString(info.mon.get(index));
            setEntryColour(text);
            final TextView textV = (TextView) findViewById(timeId);
            textV.setTextSize(10);
            textV.setText(text, BufferType.SPANNABLE);
            textV.setId(id);
            deleteGridEntry(textV);
        } else {
            longerDuration(time, index, id, info.mon, dayOfWeek);

        }

    }

}

問題は、同じ日時に 2 つのエントリがない限り、正常に機能することです。月曜日の9時。誰にもアイデアがありますか?私はこれにまったく慣れていないので、どんな助けも大歓迎です!

データベースから引き戻された新しいデータで古い textView を上書きする簡単な方法はありませんか? id を、扱いたい textView と同じにしたいのですが、クラッシュし続けます。インスタンスと関係がありますか?

4

1 に答える 1

1

変化する:

      final TextView textV = (TextView) findViewById(timeId);

に:

        final TextView textV = (TextView) findViewById(R.id.timeId);
于 2012-05-01T09:46:40.567 に答える