Activity that is sending the putExtra()
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.onListIt
I'll give you a link where you can get the best tutorial for that... http://www.vogella.de/articles/Android/article.html
To accomplish that, you would, instead of using a different Intent
for each list item, call the same Activity
with the same Intent
, but pass extras along with it.
Let's say, for instance, that you want to pass a different String
depending on which list item is clicked. You would want to
myIntent.putExtra(String key, String value);
startActivity(myIntent);
The Activity
that you start with this Intent
will then be able to grab these extras in its onCreate()
using
Bundle extras = getIntent().getExtras();
and access the extras you put in the Intent
using the methods outlined here. This way you can use a single Activity
for all list items but have the Activity
display different information based on the extra values.