Android菜单图标未使用工具栏显示

时间:2015-04-25 07:13:45

标签: android toolbar android-menu

我的代码使用工具栏
我尝试使用How To show icons in Overflow menu in ActionBar
但没有工作

android:minSdkVersion="14"
android:targetSdkVersion="22"
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setLogo(R.drawable.ic_launcher);
setSupportActionBar(toolbar);
for(int i=0; i < NavDrawerArray.length; i++) {
    switch (i) {
        case 0:
            icon = R.drawable.ic_action_dock;
            break;
        case 1:
            icon = R.drawable.ic_action_time;
            break;
        case 2:
            icon = R.drawable.ic_action_share_nav;
            break;
        case 3:
            icon = R.drawable.ic_action_important;
            break;
        case 4:
            icon = R.drawable.ic_action_about;
            break;
        case 5:
            icon = R.drawable.ic_minimize;
            break;
        case 6:
            icon = R.drawable.ic_action_cancel;
            break;
        default:
            break;
    }
    menu.add(Menu.NONE, i, Menu.NONE, NavDrawerArray[i]).setIcon(icon);
}
return super.onCreateOptionsMenu(menu);

0 个答案:

没有答案