Android Basics – Learn how to handle Clicks in a ListActivity using onListItemClick

By now you should be familiar with a ListActivity and how to use this to display items.

So what happen’s when a user clicks on an item. How can you handle that ?

The good news is that you don’t need to use an EventListener. You can simply override onListItemClick method.

@Override
public void onListItemClick(ListView listView, View itemView, int position, long id){
    //Implement your Logic
    //Here id param is id of the item clicked. It can also be the DB unique id
}

Source code is available here

Author: androidsmartly

I am a Tech Enthusiast who likes to work on new Ideas. Sharing knowledge on Android, Marketing, Startups and More.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s