views:

347

answers:

1

Hi everybody,

I'm writing an app with ListView layout and i want to add to any line in this ListView CheckBox. How can i do this?

This is my XML file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content">
       <ListView
               android:id="@+id/listView"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:layout_weight="1">
       </ListView>
</LinearLayout>

Thanks Moshik.

+1  A: 

You could use a BaseAdapter. You can see an example here. You can pretty much add anything in a list item. You do that by overriding the getView method of the BaseAdapter. You could either create the View and add the CheckBox programmatically or you could use an xml resource file and LayoutInflater. The latter technique is used in the linked example.

kgiannakakis