I have a xml file name "list_row.xml", this was load in a 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"
/>
I use a function to load data from my table and fill in my "list_row.xml" file
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);
}
My question is how can I check the icon value to set the icon display on my listview (my data have to icon: icon_one, icon_two). Can someone help me with the code?