I'm using custom listview that has checkbox. And I want to know checkbox is checked or not. So I used getCheckedItemPositions() to get checked_info. If I set "android:clickable = "true" ", checkboxs don't return result. However if I set "android:clickable = "false" ", nothing changes in view but checkboxs return their checked information. What is problem? Bottom codes are my method that use getCheckedItemPostions() and XML code of custom listiview.
public void deleteButton(View v)
{
int i,count;
count = mMyAdapter.mItems.size();
SparseBooleanArray checked = mListView.getCheckedItemPositions();
}
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/checkBox1"
android:visibility="gone"
android:focusable="false"
android:clickable="false"
android:checkable="true"
android:layout_weight="1" />
<LinearLayout
android:layout_weight="4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:id="@+id/name"
android:layout_width="15dp"
android:layout_height="match_parent"
android:textSize="10pt"
android:text="name.." />
<TextView
android:layout_weight="1"
android:id="@+id/time"
android:layout_width="15dp"
android:layout_height="match_parent"
android:textSize="12pt"
android:text="name.." />
</LinearLayout>
<ToggleButton
android:layout_weight="1"
android:layout_gravity="right"
android:id="@+id/toggleButton3"
android:layout_width="6dp"
android:layout_height="match_parent"
android:text="Toggle"
android:textOff="Off"
android:textOn="On" />
</LinearLayout>
</LinearLayout>
Aucun commentaire:
Enregistrer un commentaire