Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android ListView中的复选框项_Android_Listview_Checkbox - Fatal编程技术网

Android ListView中的复选框项

Android ListView中的复选框项,android,listview,checkbox,Android,Listview,Checkbox,我的应用程序中有一个ListView,其中包含带有文本视图和复选框的自定义列表项 <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left" android:textColor="#5d5d5d" android:textStyle="b

我的应用程序中有一个ListView,其中包含带有文本视图和复选框的自定义列表项

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="left"
    android:textColor="#5d5d5d"
    android:textStyle="bold" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="left"
    android:textColor="#5d5d5d"
    android:textStyle="bold" />

<CheckBox
    android:id="@+id/checkBox1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:layout_alignParentLeft="true" />

您必须实现自己的适配器才能实现这一点。请创建自定义适配器。请看,这将完全按照您的需要工作。
lv.setOnItemClickListener(new OnItemClickListener() { 

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            ...
            saveListID(id);     
        }

    });
BaseAdapter adapter = new SimpleAdapter(MainActivity.this, List,
            R.layout.list_item,
            new String[] { TAG_NAME, TAG_DATE }, new int[] {
                    R.id.name, R.id.date });

    setListAdapter(adapter);