0

I am trying to localize my app from English to various other languages. I am not sure how to change the language of the action bar titles. I have included all my activities in the manifest.xml file as shown below for a single activity.

<activity
android:name=".layers"
android:label="@string/layers">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".geometry" />
</activity>

As of today, I have been able to localize my buttons, edit texts, and view texts using the following tutorial "https://www.youtube.com/watch?v=ywF-ySiBAsc". I have not figured out though how to localize all my action bar titles. I would appreciate any help towards solving this issue. I apologize for not posting any sample code, but I have not really anything to show towards localizing action bar titles.

Thanks in advance.

Koumos
  • 13
  • 3
  • See the link to change the text in you ActionBar, you would do it the same as the buttons, so you would change the string depending on the language and set the string to the ActionBar- https://stackoverflow.com/a/3438352 – HB. Dec 09 '17 at 16:48
  • Thank you very much for your valuable help. It really helped me. I was wondering though how could I extend the custom action bar to all activities. – Koumos Dec 13 '17 at 20:07
  • You will have to add it in each activity you want to use it. – HB. Dec 14 '17 at 11:04
  • That is what I imagined. Thanks again. – Koumos Dec 19 '17 at 11:24

1 Answers1

1

Create your own toolbar, give it an ID, set as an actionbar, set title using localized string:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.main_title);
andreikashin
  • 1,528
  • 3
  • 14
  • 21