ここのAndroid初心者、リストビューにアイテムを入力するのに問題があります。データベースエントリ値の1つをいつでも表示できますが、リスト行ごとに2つのアイテムが必要です。これがリストビューにデータを入力するための私のクラスです。KEY_TITLEとKEY_BODYの値をリストビューに入れたいです。理想的には、KEY_BODYをリストビューのサブアイテムにしたいのですが、APIを読んだ後でも、実装方法がわからない2アイテムのリストビューが必要になる場合があると思います。
@SuppressWarnings("deprecation")
private void fillData() {
Cursor moviesCursor = mDbHelper.fetchAllMovies();
startManagingCursor(moviesCursor);
String[] from = new String[]{
MyMoviesDBAdapter.KEY_ROWID,
MyMoviesDBAdapter.KEY_BODY,
MyMoviesDBAdapter.KEY_TITLE
};
int[] to = new int[] {
R.id.text3,
R.id.text2,
R.id.text1
};
ListAdapter movies = new SimpleCursorAdapter(this, R.layout.listtextview,
moviesCursor, from , to);
moviesCursor.moveToNext();
setListAdapter(movies);
}
これが私のXMLレイアウトです
<LinearLayout >
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dip"
android:textColor="#a4a4a4"
android:textSize="10sp"
/>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dip"
android:textColor="#ffffff"
android:textSize="24sp"
/>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="15dip"
android:textColor="#a4a4a4"
android:textSize="15sp"
/>
</LinearLayout>