Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
192 views
in Technique[技术] by (71.8m points)

java - How to change the drawer title?

I am new in Android and working on a App. I am trying to develop an App having drawer layout. Everything is fine but I can't change the Title of the drawer menu as marked on the screenshot.

Image 1: App Home

Here is the layout file for your convenience. I have taken assistance from this link:

<?xml version="1.0" encoding="utf-8"?>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/user_home_main_view">

        <Button
            android:id="@+id/button_mutual_funds_icl"
            style="@style/Widget.AppCompat.Button"
            android:layout_width="252dp"
            android:layout_height="49dp"
            android:layout_marginTop="120dp"
            android:layout_marginEnd="16dp"
            android:text="Mutual Funds of ICL"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:id="@+id/icon_mutual_funds_of_icl"
            android:layout_width="51dp"
            android:layout_height="49dp"
            android:layout_marginStart="28dp"
            android:layout_marginTop="120dp"
            android:layout_marginEnd="8dp"
            app:layout_constraintEnd_toStartOf="@+id/button_mutual_funds_icl"
            app:layout_constraintHorizontal_bias="0.384"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/mutual_funds_of_icl" />

        <Button
            android:id="@+id/button_current_nav"
            android:layout_width="252dp"
            android:layout_height="49dp"
            android:layout_marginTop="32dp"
            android:layout_marginEnd="16dp"
            android:text="Current NAVs"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/button_mutual_funds_icl" />

        <ImageView
            android:id="@+id/icon_current_nav"
            android:layout_width="51dp"
            android:layout_height="49dp"
            android:layout_marginStart="28dp"
            android:layout_marginTop="32dp"
            android:layout_marginEnd="8dp"
            app:layout_constraintEnd_toStartOf="@+id/button_current_nav"
            app:layout_constraintHorizontal_bias="0.458"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/icon_mutual_funds_of_icl"
            app:srcCompat="@drawable/net_asset_value" />

        <Button
            android:id="@+id/button_fund_performance"
            android:layout_width="250dp"
            android:layout_height="49dp"
            android:layout_marginTop="32dp"
            android:layout_marginEnd="16dp"
            android:text="Fund Performance"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/button_current_nav" />

        <ImageView
            android:id="@+id/icon_fund_performance"
            android:layout_width="51dp"
            android:layout_height="49dp"
            android:layout_marginStart="28dp"
            android:layout_marginTop="26dp"
            android:layout_marginEnd="8dp"
            app:layout_constraintEnd_toStartOf="@+id/button_fund_performance"
            app:layout_constraintHorizontal_bias="0.448"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/icon_current_nav"
            app:srcCompat="@drawable/fund_performance" />

        <Button
            android:id="@+id/button_how_to_invest"
            android:layout_width="249dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="28dp"
            android:layout_marginEnd="16dp"
            android:text="How to Invest"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/button_fund_performance" />

        <ImageView
            android:id="@+id/icon_how_to_invest"
            android:layout_width="53dp"
            android:layout_height="49dp"
            android:layout_marginStart="28dp"
            android:layout_marginTop="36dp"
            android:layout_marginEnd="8dp"
            app:layout_constraintEnd_toStartOf="@+id/button_how_to_invest"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/icon_fund_performance"
            app:srcCompat="@drawable/how_to_invest" />

        <Button
            android:id="@+id/user_home_button_invest_now"
            android:layout_width="214dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginTop="141dp"
            android:layout_marginEnd="8dp"
            android:background="@color/colorPrimary"
            android:text="Invest Now"
            android:textColor="@color/colorAccent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.513"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/button_how_to_invest" />

    </android.support.constraint.ConstraintLayout>

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:theme="@style/ThemeOverlay.AppCompat.ActionBar" />

    </FrameLayout>

    <!-- Container for contents of drawer - use NavigationView to make configuration easier -->
    <android.support.design.widget.NavigationView
        android:id="@+id/user_nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:menu="@menu/drawer_view"
        app:headerLayout="@layout/nav_header"/>


</android.support.v4.widget.DrawerLayout>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...