我有LinearLayout:
<LinearLayout
xmlns:android= "http://schemas.android.com/apk/res/android"
android:layout_width= "fill_parent"
android:layout_height= "fill_parent">
<TextView android:id="@+id/DictLink" android:layout_width="wrap_content" android:layout_height="wrap_content" ></TextView>
<CheckBox android:text="" android:id= "@+id/DictTitle" android:layout_width="fill_parent" android:layout_height="wrap_content" ></CheckBox>
</LinearLayout>
它在ListView中用作Item。下面的代码为ListView创建一个数组适配器。
ArrayList< HashMap< String, String >> adapter_list = new ArrayList< HashMap< String, String > >();
for ( String dict : dict_list )
{
String [ ] data = dict.split( ";" );
HashMap< String, String > adapter_entry = new HashMap< String, String >();
adapter_entry.put( FIELD_TITLE, data[ 0 ] );
adapter_entry.put( FIELD_LINK, data[ 2 ] );
adapter_list.add( adapter_entry );
}
String [ ] from =
{ FIELD_TITLE, FIELD_LINK };
int [ ] to =
{ R.id.DictTitle, R.id.DictLink};
final ListAdapter adapter = new SimpleAdapter( this, adapter_list, R.layout.dict_list_item , from, to );
我如何知道检查了哪些复选框?哪些复选框没有?
答案 0 :(得分:0)
ListView
类具有可以帮助您的功能:
int ListView.getCheckedItemPosition()
(适用于单选列表)
SparseBooleanArray ListView.getCheckedItemPositions()
(适用于多选列表)
还有更多: http://developer.android.com/reference/android/widget/AbsListView.html#getCheckedItemIds()