English subtitles

← From ActionBar to Toolbar (solution)

Get Embed Code
5 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. All right you're done.
  2. I'll show you what I did.
  3. As I said before,
  4. we're going to change our base app
    theme into a no action bar them.
  5. In styles.xml.
  6. Next we added a toolbar style.
  7. Again we're doing this just so we can
    set our background color consistently
  8. and also set this pop-up theme.
  9. We then reference this in our app theme.
  10. In activity_main we created a new
    linear layout for our new tool bar.
  11. So we could sit it next to
    the fragment that was already there.
  12. It was a little easier in our tablet
    version of our main activity.
  13. And again we added a linear layout
    here as well to add our toolbar
  14. in our activity detail.
  15. Finally, we had to register
    it as our action bar.
  16. So once we have set our ContentView,
    we find the Toolbar by id, and
  17. call setSupportActionBar
    on our AppCompatActivity.
  18. Then we can get the action bar
    with full action bar methods, and
  19. call setDisplayHomeAsUpEnabled
    equals true.
  20. For a detail activity.
  21. We do something similar
    in the main activity,
  22. except that we call
    setDisplayShowTitleEnabled equals false.
  23. And that's it.
  24. And there you are with
    our exciting new look.
  25. Well, as you can see it looks
    exactly as it did before,
  26. except now we're using toolbars.
  27. We'll take advantage of this later on.