0
In the Notepad example,它們顯示標題列表。你將如何改變它,以更小的字體顯示正文文本的第二行?使用SimpleCursorAdapter顯示額外文本
下面是相關代碼:
private void fillData() {
// Get all of the rows from the database and create the item list
Cursor notesCursor = mDbHelper.fetchAllNotes();
startManagingCursor(notesCursor);
// Create an array to specify the fields we want to display in the list (only TITLE)
String[] from = new String[]{NotesDbAdapter.KEY_TITLE};
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{R.id.text1};
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.notes_row, notesCursor, from, to);
setListAdapter(notes);
}
這是notes_row.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/text1" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:minWidth="100dp"/>
的意見明確規定,只顯示標題。我希望它給了我一些關於如何顯示正文文本的提示。 (我們不討論這是否是一個好主意,讓我們姑且認爲這需要做的,因爲我想在記事本例適應自己的應用程序。)