Sarath Kamisetty wrote:
> Hi,
> 
> I have a ListActivity for which I am setting up ListAdapter like below:
> 
>         phoneListAdapter = new SimpleCursorAdapter(this,
> R.layout.contacts_list_row,
>                       managedCursor, new String[] { PhonesColumns.NUMBER,
> PhonesColumns.TYPE},
>                       new int[] { R.id.text1, R.id.text2 });
>         setListAdapter(phoneListAdapter);
> 
> However, the output here is not readable as PhonesColumns.TYPE is
> displaying number strings like 2, 1 etc. A sample output that I get is
> like below:
> 
> 111-222-3333 2
> 222-333-4444 1
> 
> I want to make it more readable by converting them to "Mobile",
> "Home", "Work" etc. A sample desired output list is like below:
> 
> 111-222-3333 MOBILE
> 222-333-4444 WORK
> 
> Essentially, I don't want the columns to be displayed as is. How do I
> achieve this ? 

There are two ways to approach this: as a data problem, or as a view
problem.

As a data problem, you could create your own CursorWrapper class that
wraps your managedCursor and converts PhonesColumns.TYPE into something
more user-friendly.

I tend to look at this as a view problem, so I create a custom adapter
that creates my own views, where I can make 2, 1 be MOBILE, WORK or
different icons or whatever I feel like. I have a whole series of blog
posts up on this topic:

http://androidguys.com/?s=fancy+listviews

Forgive the formatting, and be aware that the older posts are for the M5
SDK and so need some tweaking to work on the current SDK.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to