android - How can I get the ActionBar to render? -


i'm new android development , i've been giving android studio spin. i've followed google's tutorial , still haven't been able actionbar , running either on emulator or on real device. i've specified min version in manifest file , i've edited menu , activity xml files accordingly.

confusingly, uis shown in activity_foo.xml , menu_foo.xml different:

activity_foo.xml: enter image description here

menu_foo.xml: enter image description here

even more confusingly, final app when built shows both search , settings in hamburger menu though not recall seeing in gui previews: enter image description here

how can fix this?

confusingly, uis shown in activity_foo.xml , menu_foo.xml different

they supposed different. 1 showing layout file. other showing menu resource. previews not supposed match. after all, android app bigger breadbox have many layout resources, few of defining contents of activity.

for layouts do define contents of activity, iirc, can have same tools:context=".fooactivity" in root element of layout file, , preview may take account.

even more confusingly, final app when built shows both search , settings in hamburger menu though not recall seeing in gui previews:

in preview, search item represented toolbar-style button (icon magnifying glass).

in menu resource, have 1 <item> has android:showasaction , 1 <item> has app:showasaction. either using appcompat-v7 action bar backport, or not. determined things like:

  • what java class activity inherits (actionbaractivity or appcompatactivity appcompat-v7)

  • what theme using activity in manifest (if based on theme.appcompat.*, using appcompat-v7)

if using appcompat-v7, need change android:showasaction app:showasaction. given results of run of project in emulator, guess using appcompat-v7. if make change menu resource , run project again, may see search item show magnifying glass icon, see in preview. "may" because there may or may not room show toolbar-style icon, depending on screen size , orientation of device runs app — action bar items ifroom show toolbar-style buttons if there room or fall overflow menu if not.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -