TextView とチェックボックスがあるリストビューがあります。ListView は、ローカル SQLite データベースからデータを取り込むために使用されます。ボタンがクリックされた場合、チェックボックスがオンになっている ListView サブアイテムの ID を取得するにはどうすればよいですか?
以下は私のmain.xmlです
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ListView
android:id="@+id/list_data"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_below="@+id/textViewTitle"
android:layout_marginTop="26dp"
android:layout_weight="1"
android:dividerHeight="0dip" >
</ListView>
<TextView
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Things To Remember"
android:textSize="25sp" />
</RelativeLayout>
私のsubitem.xmlファイル:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Title:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignRight="@+id/check"
android:layout_marginLeft="44dp"
android:layout_marginRight="27dp"
android:layout_toRightOf="@+id/textView1"
android:paddingBottom="5dp"
android:text="Test Data"
android:textSize="15sp" />
<CheckBox android:id="@+id/check" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginLeft="4px"
android:layout_marginRight="10px" android:layout_alignParentRight="true"
android:focusable="false"
></CheckBox>
</RelativeLayout>
私の質問は、各サブ項目のチェックボックスをオンにしてメニュー ボタンを押すと、選択した各サブ項目の ID を変数で取得する方法です。