[英]Custom ArrayAdapter
我正在创建一个应用程序,可以在其中搜索文件并将其删除。
searchstring = receivedmsg.getString("mysearch");
tv.setText("Search Results for " + searchstring);
searchForFileNameContainingSubstring(searchstring);
//ListAdapter myadapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, resList);
//lv.setAdapter(myadapter);
CustomAdapter adapter = new CustomAdapter(DataFetcher.this, android.R.layout.simple_list_item_1 , resList);
lv.setAdapter(adapter);
搜索结果显示在listview
。 如何在listview
添加复选框? 已经在Google上搜索过,但是无法正常工作。 我该如何实现?
使用所需的任何名称创建自定义布局:例如:
single_item_list.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
:
CustomAdapter adapter = new CustomAdapter(DataFetcher.this, R.layout.single_item_list , resList);
并处理customAdapter
功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.