onItemClick

Android Custom Listview Tutorial - Part 2

Moving ahead from first part Custom List view,  we are going to discuss three things.

1.Adding background colors to Listview

2.Adding different Divider color.

3.Triggering action on listview click.

Step 1:

Listview Background Color

Adding Custom Background color to listview . For an elegance look for an application the listview color play a key role.

[sourcecode language="java"]

convertView.setBackgroundColor((position & 1) == 1 ? Color.WHITE : Color.LTGRAY);

[/sourcecode]

Android Listview Onclick

By using setOnClickItemListener() we can get the clicked item in android listview.

Syndicate content