如果我的ListView
的佈局在下面,每個項目都有一個複選框,那麼當我點擊Button
時,如何獲得onClick()
方法中的所有選中項目?從ListView中獲取所有選中的項目
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:onClick="submitList"
/>
</RelativeLayout>
的onClick()
方法:
public void submitList(View view) {
//
}
你到目前爲止試過的東西? – Amy
請參閱以下內容[Android - 從ListView中使用CheckBox獲取所選項目](http://kb4dev.com/tutorial/android-listview/checkbox-in-listview--event-handling--1) –