appcompat - Android appcompact Toolbar title from manifest -


im using appcompat toolbar in drawer layout inside fragmentactivity. inside each fragmentactivity need change title based on activity. there way set title manifest instead of setting in each activity oncreate toolbar.settitle("abc").

note: im not using getsupportactionbar(toolbar)

firstactivity extends baseactivity

themes.xml

<style name="apptheme.base" parent="theme.appcompat.light">     <item name="colorprimary">@color/primary</item>     <item name="colorprimarydark">@color/primarydarker</item>     <item name="android:windownotitle">true</item>     <item name="windowactionbar">false</item>     <item name="drawerarrowstyle">@style/drawerarrowstyle</item> </style>  <style name="drawerarrowstyle" parent="widget.appcompat.drawerarrowtoggle">     <item name="spinbars">true</item>     <item name="color">@android:color/white</item> </style>  <color name="primary">#457c50</color> <color name="primarydarker">#580c0c</color> 

android manifest

<activity     android:name="com.sample.md.firstactivity"     android:configchanges="orientation|screensize|keyboardhidden"     android:label="first activity" >             </activity> 

toolbar initialize in base activity

android.support.v7.widget.toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); android.support.v7.app.actionbardrawertoggle mdrawertoggle =      new actionbardrawertoggle(this, mdrawerlayout, toolbar, r.string.drawer_open, r.string.drawer_close) {          @override         public void ondrawerclosed(view view) {             super.ondrawerclosed(view);             try {                 toolbar.settitle(mtitle);             } catch (exception e) {                 e.printstacktrace();             }             invalidateoptionsmenu();             syncstate();         }          @override         public void ondraweropened(view drawerview) {             super.ondraweropened(drawerview);             toolbar.settitle("menu");             invalidateoptionsmenu();             syncstate();         }  };  mdrawertoggle.setdrawerindicatorenabled(true); mdrawerlayout.setdrawerlistener(mdrawertoggle); mdrawertoggle.syncstate(); 

you should able set label attribute.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -