JUN wrote:
> ...
> Cursor c = ppp.getAll();
>
> String[] from = new String[] {"name","gender","address"};
>
> int[] to = new int[] { R.id.text1,R.id.text2,R.id.text3};
>
> SimpleCursorAdapter peoples = new SimpleCursorAdapter
> (this,R.layout.money_row, c, from, to);
>
> setListAdapter(peoples );
>
> i get the data from database, and list it in listview, now it can
> display normally with all textview.
>
> the gender field, it display text also, i want to replace it with
> icon. how can i do it?
http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html
Option #1: Attach a SimpleCursorAdapter.ViewBinder via setViewBinder(),
replace R.id.text2 with R.id.this_is_an_image_view (or whatever you want
to call it), and have the ViewBinder associate the icon.
Option #2: Extend your SimpleCursorAdapter and implement setViewImage().
You will also need to replace R.id.text2 with R.id.this_is_an_image_view
(or whatever you want to call it).
Option #3: Extend your SimpleCursorAdapter and implement bindView(), and
in there populate all your widgets for a given row by hand.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Android Development Wiki: http://wiki.andmob.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---