custom list in android
I am creating a android app in which 开发者_如何转开发i have a list of contacts. I am displaying the list of contacts in the list view using the following code :
setListAdapter(new ArrayAdapter(
getApplicationContext(),
android.R.layout.simple_list_item_1, ct_name));
where the variable ct_name is an array containing contact names. Now i want to add 2 images in front of each contact. The images are for calling and messaging option. The images will be same for all the contacts. Could anyone tell me how to display the 2 images in the list along with the contacts. As far as i have searched I guess i would have to make a custom adapter but i am not able to follow on how to do so. Could anyone help me with this?
You have to implement a custom ListAdapter.
See this tutorial:
http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/
A Custom List Adapter is must for creating ListView
in Andorid.
If you want to create awesome Custom ListView in android, don't miss to read & copy-paste code of following tutorial.
Android Custom ListView Example with Images
精彩评论