Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
changing screen title based on open fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
smukov committed Jul 5, 2016
1 parent 05bd632 commit fdc1be9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public void onClick(View view) {
fragmentManager.beginTransaction()
.replace(R.id.content_frame ,(Fragment) currentFragment)
.commit();

setTitle(R.string.titleMyProfile);
}

@Override
Expand Down Expand Up @@ -99,6 +101,8 @@ public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();

setTitle(item.getTitle());

if (id == R.id.nav_contacts) {
currentFragment = new ContactsFragment();

Expand Down
8 changes: 4 additions & 4 deletions Android/app/src/main/res/menu/activity_navigation_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
android:checked="true"
android:id="@+id/nav_my_profile"
android:icon="@drawable/ic_person_black_24dp"
android:title="My Profile" />
android:title="@string/titleMyProfile" />
<item
android:id="@+id/nav_contacts"
android:icon="@drawable/ic_people_black_24dp"
android:title="My Contacts" />
android:title="@string/titleMyContacts" />
</group>

<group
Expand All @@ -21,11 +21,11 @@
<item
android:id="@+id/nav_settings"
android:icon="@drawable/ic_settings_black_24dp"
android:title="Settings" />
android:title="@string/titleSettings" />
<item
android:id="@+id/nav_send_feedback"
android:icon="@drawable/ic_menu_send"
android:title="Send Feedback" />
android:title="@string/titleSendFeedback" />
</group>

</menu>
7 changes: 7 additions & 0 deletions Android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
<string name="action_settings">Settings</string>
<string name="title_activity_login">Sign in</string>

<!-- Fragment Titles -->
<string name="titleMyProfile">My Profile</string>
<string name="titleMyContacts">My Contacts</string>
<string name="titleContact">Contact</string>
<string name="titleSettings">Settings</string>
<string name="titleSendFeedback">Send Feedback</string>

<!-- Strings related to login -->
<string name="prompt_email">Email</string>
<string name="prompt_password">Password (optional)</string>
Expand Down

0 comments on commit fdc1be9

Please sign in to comment.