开发者

How to add CheckBox to any ListView item in android?

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">
       开发者_Python百科<ListView
               android:id="@+id/listView"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:layout_weight="1">
       </ListView>
</LinearLayout>

Thanks Moshik.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜