Open dimparf opened 7 years ago
Hi @dimparf ,
Thanks for your kind words!
To work with the Toolbar, simply add one in your activity xml ad set it up like you would normally do, then you can set a NavigationListener and implement onNavigate(ActionBarConfig actionBarConfig)
to manipulate the toolbar. You can also use onUpdateMenu()
on a screen to update the menu.
We hope to do some of this for you eventually, but this way, you have full control.
This definitely need some more documentation / example.
Hope this answer your question,
Fabien
Thanks @fabiendevos
@fabiendevos My activity xml contains ScreenContainer as root. Where should I add a toolbar?
You can wrap it in a LinearLayout and add the Toolbar on top of the ScreenContainer for example. The ScreenContainer
is where the swapping of the Screen's Views will happen.
@fabiendevos But if I doing it @Override public String getTitle(Context context) { return context.getResources().getString(R.string.main_screen_title); } not working (title not showing and changing by change screen).
True: you also need to set your toolbar as the Action Bar by using: http://developer.android.com/reference/android/support/v7/app/AppCompatActivity.html#setSupportActionBar(android.support.v7.widget.Toolbar)
Definitely need some more examples / helper code
I added a page to the wiki for working with the action bar that should help you get set up.
Also check out the changes in #34
@wclausen It does not for me, I followed the instructions in the wiki page but I can't get it to work, I get a 'Cannot resolve method setActionBarColor', the same with showActionBar and hideActionBar. Am I supposed to create the methods myself? Am I missing some import? I'm not very experienced and I'm finding the wiki pages to be very vague.Please help.
In this case, with the class extending AppCompatActivity, where exactly do I have to call:
Navigator.withRoot(HomeScreen()).build()
Obs.: I'm using Kotlin.
@felipebelluco : are you using SingleActivity? Did you look at the wiki page Working With The Action Bar and at this code: #34 ?
@OmarCantuariasSaleh try to look at the advanced sample and at this code: #34
@fabiendevos no because the wiki Ensure your Activity extends AppCompatActivity says to use AppComparActivity.
@felipebelluco yes, for now, you need to basically copy he code of SingleActivity and maye it inherit from AppCompatActivity, something like that: https://github.com/wealthfront/magellan/blob/f16857e4aebab9752c9df4d85f7295e6327e2abf/magellan-sample-advanced/src/main/java/com/wealthfront/magellan/sample/advanced/MainActivity.java
(in this example, the Navigator is injected as a singleton, but you can simply keep it in a static field to achieve the same result without the need for dependency injection)
Thanks for great and simple library. How to work with Toolbar menu and back button on Toolbar?