データベースからアイテムのリストを作成しようとしています。 imageViewを表示するために、通常の行ではなく行としてlinearLayoutを展開したいとします。行として直線レイアウトを膨張させるにはどうすればよいですか?
ここは私のXML for my row.xml linearLayoutです。
?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="4dip">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop = "true"
android:layout_alignParentBottom = "true"
android:layout_marginRight="4dip"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:textColor="#15317E"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textStyle="bold"
android:maxLines="1"
android:textSize="21dip"
android:ellipsize="end"
/>
</LinearLayout>
</LinearLayout>
は、今ここで私は、List.xmlの
public void fillData(){
helper.open();
Cursor task = helper.fetchAllTask();
startManagingCursor(task);
String[] from = new String[]{TaskHelper.KEY_TITLE};
int[] to = new int[]{R.layout.row};
SimpleCursorAdapter taskAdapter = new SimpleCursorAdapter(this, R.layout.list, task, from , to);
setListAdapter(taskAdapter);
}
イム誰かがこれに精通している場合はイムは、この権利を行うかどうかわからないでレイアウトを表示するためにSimpleCursorAdapterを使用しています。私にお知らせください。 ありがとう
私のfillData()では、アイコンとしてimageViewも表示したいと思います。しかし、私はアイテムを追加するたびに何らかの理由で値を設定しません。おそらく、私はリスト全体を再構築できるより良い方法です。
を試してみてください、あなたは後
fillData
を呼び出す場合はGUIのスレッドでsetListAdapter(taskAdapter)
を呼び出して試してみてくださいリストの項目。 emoty = "アイテムはありません" – yoshi24