操作栏中的设置

时间:2018-05-01 10:57:58

标签: android android-actionbar

(1)我想删除在使用Navigation Drawer Activity创建新项目后创建的设置图标。
(2)并且我想将项目的标题更改为红色我是一个activity_main_drawer.xml。
(3)最后一个,我还要删除操作栏的标题。

操作栏的屏幕截图: enter image description here

菜单项代码:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:showIn="navigation_view">

    <group android:checkableBehavior="single">
        <item android:title="Asosiy menyu" 
             >

            <menu>
            <item
            android:id="@+id/nav_camera"
            android:icon="@drawable/ic_star_black_24dp"
            android:title="Yoqtirganlar" />
        <item
            android:id="@+id/nav_gallery"
            android:icon="@drawable/ic_format_list_bulleted_black_24dp"
            android:title="So'ngi ko'rilganlar" />

            </menu>
        </item>
    </group>
</menu>

导航菜单的标题:

enter image description here

1 个答案:

答案 0 :(得分:0)

您的第一个问题是从活动代码中删除以下代码。

    @Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main2, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

然后没有显示设置..

  1. 在删除

    中的string.xml中
    <string name="app_name">RafDemo</string> // here give empty no show title in actionbar.