How to add CheckBox to any ListView item in android?

I am writing an application with a ListView layout and I want to add any row 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.

+2


a source to share


1 answer


You can use BaseAdapter. You can see an example here . You can add anything to the list item. You do this by overriding BaseAdapter's getView method. You can either create a View, add CheckBox programmatically, or use xml resource file and LayoutInflater. The last method is used in the linked example.



+1


a source







All Articles