Android-复选框阻止CreateContextMenu
我注册列表的关联菜单:Android-复选框阻止CreateContextMenu,android,listview,checkbox,Android,Listview,Checkbox,我注册列表的关联菜单: this.registerForContextMenu(listView); 并实施所需的方法: @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
this.registerForContextMenu(listView);
并实施所需的方法:
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
menu.setHeaderTitle("title");
String[] rssContextMenuItems = this.getResources().getStringArray(R.array.my_array);
for (int i = 0; i < rssContextMenuItems.length; i++)
menu.add(Menu.NONE, i, i, rssContextMenuItems[i]);
}
问题是列表中有一个自定义视图,其中包含一个复选框
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:orientation="horizontal" >
<!-- some elements -->
<CheckBox
android:id="@+id/my_id"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false" />
<!-- some more -->
</LinearLayout>
我已经尝试过android:focusable=false和android:focusableInTouchMode=false技巧,但是当我长按复选框时,它仍然不会触发onCreateContextMenu方法
有什么方法可以让它工作吗?我所做的是为复选框的文本创建一个文本视图。我没有将文本值放入复选框小部件。所以我在它旁边创建了一个文本视图。