@Override protected void onListItemClick(ListView l, View v, int position, long id) { alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Item Selected"); alertDialog.setMessage("You just clicked an item position #" + String.valueOf(position)); alertDialog.setButton("OK",new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); super.onListItemClick(l, v, position, id); }
Quick Explanation
Here all we need to do it implement a function, onListItemClick, you can do this in eclipse by Right Click->Source->Override/Implement Method->onListItemClick.
There would be 4 arguments ListView l, View v, int position, long id, view this to see that they mean.
References
Display Contact Names in Android
Displaying AlertDialog in Android
android.app.ListActivity
Source
Main.java of Clicking Items in ListActivity

Update History
Jan 17, 2012 - Visual Update
2 comments:
Not complex, but it has helped me. Thanks
Thanks for this, helped a lot
Post a Comment