How to write onclick event for ListView in Android?
Posted
by Srikanth Naidu
on Stack Overflow
See other posts from Stack Overflow
or by Srikanth Naidu
Published on 2010-05-31T14:21:07Z
Indexed on
2010/05/31
14:23 UTC
Read the original article
Hit count: 738
Hi i have the listview the sixitems in it, but when i call alet function on event it doesnt work ? let me know how to write a function on item event on click?
public class PhotoListView extends ListActivity {
String[] listItems = {"HeadShot", "BodyShot ", "ExtraShot", "Video Take1", "Video Take2", "Video Take3", };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setListAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1, listItems));
}
OnListclick
ListView Shot = getListView(); protected void onListItemClick(View view) {
if(view == Shot){
AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
// set the message to display
alertbox.setMessage("Please Get Ready");
}
© Stack Overflow or respective owner