I’m trying to make an app which displays a listview, and when you click on a specific item in that list, it will display a toast with specific information.
So far example, I got this code from this site:
public class MyListActivity extends ListActivity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
Toast.makeText(this, item + " selected", Toast.LENGTH_LONG);
}
So how would I modify the code, for example, to display a toast containing information about Android when one clicks “android” in the list? And of course, then a different toast containing different info will be displayed when one clicks on “iPhone” etc.
Thanks for any help you can give 🙂
make
String[] valuesa class variable .toast.show() is missing .
Updating