How to set different icon for ListView?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to set different icon for ListView?

Postby dennie » Wed Aug 19, 2009 4:41 am

How to set different icon for ListView with data get from database? My code here:

Code: Select all
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);
}


And my layout xml:

Code: Select all
<?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"           
/>
dennie
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sat Jul 18, 2009 8:10 am

Top

Postby gecu_121 » Wed Aug 19, 2009 8:19 pm

hello,
read the following tutorial from plusminus. I hope it will solve your problem.

Iconified list
gecu_121
Junior Developer
Junior Developer
 
Posts: 17
Joined: Thu Jul 30, 2009 2:39 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 12 guests