【发布时间】:2010-11-19 14:06:48
【问题描述】:
我有一个 xml 文件名“list_row.xml”,这是在 listView 中加载的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_one"
/>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
我使用一个函数从我的表中加载数据并填写我的“list_row.xml”文件
private void fillData() {
Cursor c = mDbHelper.fetchAllNotes();
String[] from = new String[]{ ListDbAdapter.KEY_ROWID,
ListDbAdapter.KEY_ICON, ListDbAdapter.KEY_LABEL };
int[] to = new int[]{ R.id.id, R.id.icon, R.id.label };
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, R.layout.list_row, c, from, to );
setListAdapter(adapter);
}
我的问题是如何检查图标值以在列表视图上设置图标显示(我的数据必须为图标:icon_one、icon_two)。有人可以帮我写代码吗?
【问题讨论】: