Tuesday, May 1, 2012

[android-developers] Custom ListView with Checkbox

I am creating a ListView using customized TextView, as shown below:

list_item.xml file:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp"
android:background="#ffffff"
android:textColor="#000000">

Activity file extending ListActivity:

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,
COUNTRIES));

Normally we use this code for multiple list item selection:

setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice,
hometown));

But I have changed the 2nd argument of ArrayAdapter to my customized
TextView, hence i dont understand where to put the option for multiple
choice of list items.

Please Help

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment