将自定义复选框添加到ArrayAdapter [英] Add custom checkbox to ArrayAdapter
本文介绍了将自定义复选框添加到ArrayAdapter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用SQLite
数据库保存记录,在返回记录时,我正在使用以下代码:
I am using SQLite
database to save my records, on returning them I am using this code:
mydb = new DBHelper(this);
ArrayList array_list = mydb.getAllItems();
ArrayAdapter arrayAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_1, array_list);
mRecyclerview =(RecyclerView) findViewById(R.id.items_List);
obj = (ListView)findViewById(R.id.listView1);
obj.setAdapter(arrayAdapter);
但是,这向我显示了正常的项目列表,我想在每行上显示一个带有CheckBox
的列表.我尝试使用BaseAdapter
,也尝试了RecyclerView
,但是它不起作用.是否可以自定义simple_list_item_1?
But this is showing me a normal list of items and I want to display a list with CheckBox
on every row. I tried using BaseAdapter
and also tried RecyclerView
but Its just not working. Is there a way to customize the simple_list_item_1?
推荐答案
您是否尝试过 CheckedTextview ,您可以
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/checkedTextView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="center|left"
android:textColor="@color/black_color"
android:drawablePadding="5dp"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:textSize="12dp"
/>
这篇关于将自定义复选框添加到ArrayAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文