Java 定制阵列适配器
我正在创建一个应用程序,可以在其中搜索并删除文件。Java 定制阵列适配器,java,android,android-arrayadapter,Java,Android,Android Arrayadapter,我正在创建一个应用程序,可以在其中搜索并删除文件。 searchstring=receivedmsg.getString(“mysearch”); tv.setText(“对“+搜索字符串的搜索结果”); SearchForFileName包含子字符串(searchstring); //ListAdapter myadapter=new ArrayAdapter(这是android.R.layout.simple\u list\u item\u 1,resList); //lv.设置适配器(m
searchstring=receivedmsg.getString(“mysearch”);
tv.setText(“对“+搜索字符串的搜索结果”);
SearchForFileName包含子字符串(searchstring);
//ListAdapter myadapter=new ArrayAdapter(这是android.R.layout.simple\u list\u item\u 1,resList);
//lv.设置适配器(myadapter);
CustomAdapter=新的CustomAdapter(DataFetcher.this,android.R.layout.simple\u list\u item\u 1,resList);
低压设置适配器(适配器);
搜索结果显示在列表视图中。如何在列表视图中添加复选框?
已经在谷歌上搜索过了,但它不起作用。如何实现这一点?使用您想要的任何名称创建自定义布局:
例如:
单个项目列表.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="wrap_content"
android:orientation="vertical"
android:padding="6dip" >
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="CheckBox" />
<TextView
android:id="@+id/code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/checkBox1"
android:layout_alignBottom="@+id/checkBox1"
android:layout_toRightOf="@+id/checkBox1"
android:text="TextView" />
</RelativeLayout>
并在customAdapter
中处理功能选中此复选框您必须创建用于添加复选框的自定义单列表布局可能重复
<?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="wrap_content"
android:orientation="vertical"
android:padding="6dip" >
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="CheckBox" />
<TextView
android:id="@+id/code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/checkBox1"
android:layout_alignBottom="@+id/checkBox1"
android:layout_toRightOf="@+id/checkBox1"
android:text="TextView" />
</RelativeLayout>
CustomAdapter adapter = new CustomAdapter(DataFetcher.this, R.layout.single_item_list , resList);