tags:

views:

13

answers:

1

I have an screen that displays all the names in the Contacts in a ListView.

When the user clicks on a name, I want to launch another Activity which display the details of the selected Contact (Phone number/ email) in another screen. How do I display details for the selected row. (i.e When starting the intent how do I send over the row_id of the item selected)?

I've tried the following code:

    Intent i = new Intent(this, ContactDetails.class);
    startActivity(i);
+2  A: 

Package it as an extra:

i.putExtra("MyReallyCoolContactID", id);

Then, ContactDetails can call getIntent().getExtra("MyReallyCoolContactID") to get the ID of the contact of interest.

CommonsWare
Thanks! You answer was very helpful.The only change I made was that, since I couldn't find Intent.getExtra(String) method, I used the following: Bundle b = getIntent().getExtras(); long id = (Long)b.get("MyReallyCoolContactID");
OceanBlue