Skip to content Skip to sidebar Skip to footer

How To Implement Onclicklistener For Listview

I have an activity (MainActivity) which calls on a 2nd Activity (ImageAndTextAdapter) to display a listview. I want to be able to click on each list item to open a new activity. H

Solution 1:

In your onCreate() method, after setListAdapter(new ImageAndTextAdapter(ctx, R.layout.main_list_item, options, icons));, use:

getListView().setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position,
            long id) {
        // Handle your click here as you want

    }
});

Post a Comment for "How To Implement Onclicklistener For Listview"