0

私はAndroidNotepadチュートリアルの修正バージョンに取り組んでいます。次のコードは、基本的にすべてのノートのタイトルをテーブル画面に表示するfillData関数からのものですが、わずかに変更されています。

Cursor notesCursor = mDbHelper.fetchAllNotes();
startManagingCursor(notesCursor);

String[] from = new String[]{NotesDbAdapter.KEY_TITLE, NotesDbAdapter.KEY_SPECIAL};
int[] to = new int[]{R.id.text1, R.id.text2};

SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.notes_row, notesCursor, from, to);
setListAdapter(notes);

notes_row.xmlファイルは非常に単純です。

<TextView
    android:id="@+id/text1"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

How can I add @+id/text1 to this XML file so that when the KEY_SPECIAL field is set to true (or 1), the TextView is bolded? What if I want to use CheckedTextView and get the checkmark instead of bold? How do I write the XML file to look for that input to determine if it's checked originally?

4

1 に答える 1

0

実行時にのみ認識される条件に基づいてテキストを変更するには、独自のカスタム アダプターを作成する必要があります。シンプルなアダプターは、すべての行にタイトルとサブタイトルを配置するために機能しますが、それ以上のものが必要な場合は、カスタムにする必要があります.

Android : BaseAdapter をご覧ください。.

于 2011-05-19T23:58:39.073 に答える