Adding a onItemClickListener to the List

Refer to the previous post to create a list and add the following extensions to the code in the main activity

in the onCreate method


create the listener

private AdapterView.OnItemClickListener onListClick = new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(getApplicationContext(),”Click ListItem Number: ” + position, Toast.LENGTH_LONG).show();

Now when you click on the list item, you see a pop up of the List Item Number


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: