0

I'm working on a modified version of the Android Notepad tutorial. The following code is from the fillData function which basically displays the titles of all the notes on a table screen, slightly modified:

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);

The notes_row.xml file, is very simple:

<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?

1 Answers1

0

You will need to write your own custom adapter to have text change based on conditions that are only known at runtime. The Simple adapters work for putting a title and subtitle on every row, but if you need anything more than that you need to go custom.

Take a look at Android : BaseAdapter how to?.

Community
  • 1
  • 1
Austyn Mahoney
  • 11,398
  • 8
  • 64
  • 85