【android组件】Menu

UI

正常设置:

【android组件】Menu【android组件】Menu
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/menu_filter"
        android:icon="@drawable/ic_filter_list"
        android:title="filter"
        app:showAsAction="always" />
    <item
        android:id="@+id/easy"
        android:title="easy" />
    <item
        android:id="@+id/medium"
        android:title="medium" />
    <item
        android:id="@+id/hard"
        android:title="hard" />
</menu>
View Code

显示最左边三杠

【android组件】Menu【android组件】Menu
//        ab.setHomeAsUpIndicator(R.drawable.ic_menu);
//        ab.setDisplayHomeAsUpEnabled(true);
View Code

注入

【android组件】Menu【android组件】Menu
@Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.difficulty_menu, menu);
        inflater.inflate(R.menu.filter_tasks,menu);
    }


public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        setHasOptionsMenu(true);
        return root;
    }
View Code

相关推荐