Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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,我有一个列表视图,它为每一行膨胀一个xml,其中包含一个复选框,还有更多文本视图位于相对视图中。 问题是我不知道如何将onClick事件从复选框传递到后排。 我想实现这个行为:用户按下复选框,整个列表行被按下。如果我为android.R.layout.simple\u list\u item\u multiple\u choice每一行充气,我就看到了这种行为,但是如果没有这个android特定的布局,我想不出怎么做 谁能给我一个想法或方向 代码如下: 列表视图: <ListView

我有一个
列表视图
,它为每一行膨胀一个xml,其中包含一个
复选框
,还有更多
文本视图
位于
相对视图
中。 问题是我不知道如何将onClick事件从复选框传递到后排。 我想实现这个行为:用户按下复选框,整个列表行被按下。如果我为android.R.layout.simple\u list\u item\u multiple\u choice每一行充气,我就看到了这种行为,但是如果没有这个android特定的布局,我想不出怎么做

谁能给我一个想法或方向

代码如下:

列表视图:

<ListView
    android:id="@+id/include_sent_list_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/white"
    android:cacheColorHint="@color/white"
    android:layout_alignParentTop="true"/>

以及为每行膨胀的xml:

<RelativeLayout 
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

<CheckBox
        android:id="@+id/checked_radio_button"
        android:layout_width="50dp"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:focusable="false"
        />
<TextView
        android:id="@+id/account_number_text"
        android:layout_width="100dp"
        android:layout_height="fill_parent"
        style="@style/config_simple_small_text_view_style"
        android:paddingTop="15dp"
        android:layout_toRightOf="@id/checked_radio_button"

        />
<TextView
        android:id="@+id/account_name_text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        style="@style/config_simple_small_text_view_style"
        android:paddingTop="15dp"
        android:layout_toRightOf="@id/account_number_text"/>

</RelativeLayout>

复选框使用列表项的焦点。您需要在布局文件中设置:

<!-- Must make this non-focusable otherwise it consumes  -->  
<!-- events intended for the list item (i.e. long press) -->
<CheckBox
    android:id="@+id/item_entry_check"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:focusable="false"
    />


我尝试了这个,但似乎不起作用。我想这不会发生,因为我将此视图充气以列出看起来不错的行。.java?.java代码看起来像一个正常的膨胀过程。屏幕已正确充气,但复选框会获取单击事件。android.R.layout.simple\u list\u item\u多项选择可以以某种方式实现这一点,但我不知道如何实现