Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.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 上下文菜单不支持';行布局中有开关时不能工作_Android_Android Contextmenu - Fatal编程技术网

Android 上下文菜单不支持';行布局中有开关时不能工作

Android 上下文菜单不支持';行布局中有开关时不能工作,android,android-contextmenu,Android,Android Contextmenu,我的片段中有一个带有自定义适配器(从ArrayAdapter扩展而来)的ListView。 list.xml: ... <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" /> ... 如果rowlayout中没有开关,则所有工作正常。但若它添加了,那个么当单击行时什么也并没有发生。 如

我的片段中有一个带有自定义适配器(从ArrayAdapter扩展而来)的ListView。 list.xml:

...
    <ListView android:id="@android:id/list" android:layout_width="match_parent"
        android:layout_height="match_parent" />
...
如果rowlayout中没有
开关
,则所有工作正常。但若它添加了,那个么当单击行时什么也并没有发生。 如何解决此问题并同时使用上下文菜单和开关?

添加

android:descendantFocusability="blocksDescendants"
到你的直线上

到您的文本视图


转到您的交换机

谢谢!你帮了我这么多!
...
        mListView = (AbsListView) view.findViewById(android.R.id.list); //my list
        mListView.setAdapter(adapter);
        mListView.setOnItemClickListener(this);
        registerForContextMenu(mListView); //set up context menu
...
android:descendantFocusability="blocksDescendants"
android:textIsSelectable="false"
android:focusable="false"