使用自定义Listview Android检查CheckBox的值 [英] Checked values of CheckBox with Custom Listview android
本文介绍了使用自定义Listview Android检查CheckBox的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用自定义 ListView
绑定复选框
.现在,最后,我想要所有选中的 CheckBox
的值.
如何获得此值?我想知道如何使用我的代码获取值. ListView itemOnClickListener
不在此处触发.
我的代码:
I am binding Checkbox
using Custom ListView
. Now, at the last, I want all the values of checked CheckBox
.
How to get this ? I want to know that how can I get values using my code. ListView itemOnClickListener
is not firing here.
My code :
Map<String, String> m = null;
for (int i = 0; i < lList.size(); i++) {
objSubCatData = lList.get(i);
lstSubCatId.add(objSubCatData.getSubCatId());
m = new HashMap<String, String>();
m.put("SubCatName", objSubCatData.getSubCatName());
aaSubCategory.add(m);
}
final SimpleAdapter adapter = new SimpleAdapter(UserInterest.this, aaSubCategory, R.layout.userinterest_1, new String[] { "SubCatName" }, new int[] { R.id.chkUserInterest });
lvUserInterest.setAdapter(adapter);
layout1.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/datalist"
android:orientation="vertical" >
<CheckBox
android:id="@+id/chkUserInterest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/blue"
android:textSize="14sp" >
</CheckBox>
</LinearLayout>
Layout2.xml:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@+id/lvUserInterest"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="8dp"
android:divider="#b5b5b5"
android:dividerHeight="1dp" />
<Button
android:id="@+id/btnUTSubmit"
android:layout_width="130dp"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_marginTop="6dp"
android:background="@drawable/blue_bg"
android:text="@string/Submit"
android:textColor="@color/white" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/userinterest"
android:textColor="@color/gray" />
</LinearLayout>
推荐答案
I have solved my problem by this website : mysamplecode.com/2012/07/android-listview-checkbox-example.html
这篇关于使用自定义Listview Android检查CheckBox的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文