Working with adapters

Put your problem here if it does not fit any of the other categories.

Working with adapters

Postby szimek » Fri Dec 21, 2007 9:43 pm

Hi!

I thought it should be simple, but I can't figure out how to do it. I've got 2 text fields: phone type and number. I can easily get phone type as integer from Phones.TYPE, but I'd like to display something more meaningful than 1 or 0 :)

Right now I've got code almost straight from one of the tutorials:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Cursor c = getContentResolver().query(Phones.CONTENT_URI,
  3.  
  4.                                                                           null,
  5.  
  6.                                                                           Phones.PERSON_ID + "=" + personId,
  7.  
  8.                                                                           null,
  9.  
  10.                                                                           null);
  11.  
  12. String[] columns = new String[] { Phones.TYPE, Phones.NUMBER_KEY };
  13.  
  14. int[] phones = new int[] {R.id.phone_type, R.id.phone_number};
  15.  
  16.  
  17.  
  18. mAdapter = new SimpleCursorAdapter(this, R.layout.phones_list, c, columns, phones);
  19.  
  20. setListAdapter(mAdapter);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

How to modify it to return a string (i.e. from a hash map, where keys would be constants from Phones.TYPE) instead of integers? I need something like SimpleCursorAdapter, but with ability to specify some kind of mapping using i.e. a hash map.

Thanks in advance!
szimek
Freshman
Freshman
 
Posts: 6
Joined: Wed Dec 19, 2007 3:38 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 23 guests