Menu item click hides popup

你。 提交于 2019-12-11 03:46:31

问题


I have list of items with checkboxes in my menu:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".ListActivity">
    <group
        android:checkableBehavior="all"
        android:orderInCategory="1">
        <item
            android:id="@+id/all"
            android:checkable="true"
            android:checked="true"
            android:icon="@android:drawable/ic_menu_preferences"
            android:title="@string/category_all" />
        <item
            android:id="@+id/entertainment"
            android:checkable="true"
            android:checked="true"
            android:title="@string/category_1" />
        <item
            android:id="@+id/sport"
            android:checkable="true"
            android:checked="true"
            android:title="@string/category_2" />
        <item
            android:id="@+id/recreation"
            android:checkable="true"
            android:checked="true"
            android:title="@string/category_3" />
    </group>
</menu>

but if I click on any item is, the window closes. I know, it should work like this. But I need keep this popup open. Please help me somebody!


回答1:


Try using "return false " in onOptionsItemSelected method . hope it will work for you !!



来源:https://stackoverflow.com/questions/32948701/menu-item-click-hides-popup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!