Any ideas anyone? I have gotten the contacts information, but I have not been able to corretly associate the contacts information when the list item is clicked. Any thoughts?
On Apr 6, 9:29 am, Timothy Passaro <[email protected]> wrote: > Hey guys, I have a few questions concerning listView and cursors. > First, I know theres a method called bindView(), and I was wondering > if this implies that you can tie extra data to each list item. My > objective is to putExtras() to another activity after a contacts name > is clicked on. I figured that it would be very easy to accomplish if > the data was already in the listview object (or something to that > extent). I am not sure how to go about doing something like this! > Also, concerning cursors and retrieving data. I have code that > actually works to get the contacts of the phone, but I am not sure > exactly what it does, and I do not understand the parameters that > query on a ContentResolver are (ie Projection and such). Anyone have a > nice explanation on how this works? Thanks for any help! > > public class MainPage extends ListActivity { > > private ListAdapter adapter; > private Cursor c; > private ArrayList<String> names; > > @Override > public void onCreate(Bundle icicle) { > super.onCreate(icicle); > ContentResolver cr = getContentResolver(); > c = cr.query(ContactsContract.Contacts.CONTENT_URI, null, > null, null,null); > > names = new ArrayList<String>(); > > while(c.moveToNext()){ > String name = > c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); > String number = > c.getString(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); > if(number.equals("0")) continue; > names.add(name); > } > > adapter = new ArrayAdapter<String>(this, > android.R.layout.simple_list_item_1, names); > setListAdapter(adapter); > getListView().setTextFilterEnabled(true); > > } > > @Override > public void onListItemClick(ListView l, View v, int position, long id) > { > super.onListItemClick(l, v, position, id); > Intent newIntent = new Intent(Intent.ACTION_MAIN); > newIntent.setClass(this, Summary.class); > newIntent.putExtra("com.grey.gui.MainPage", "banana"); > startActivity(newIntent); > } > > > > } -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android 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

