java - problems with adding action button in android tutorial -


i following android tutorial , have problems adding search button action bar.

i have following main_activity_actions.xml because support android version 8:

<menu xmlns:android="http://schemas.android.com/apk/res/android"      xmlns:yourapp="http://schemas.android.com/apk/res-auto" >     <!-- search, should appear action button -->     <item android:id="@+id/action_search"           android:icon="@drawable/ic_action_search"           android:title="@string/action_search"           yourapp:showasaction="ifroom" />     <!-- settings, should in overflow -->     <item android:id="@+id/action_settings"           android:title="@string/action_settings"           yourapp:showasaction="never" /> </menu> 

then in mainactivity class:

@override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu items use in action bar         menuinflater inflater = getmenuinflater();         inflater.inflate(r.menu.main_activity_actions, menu);         return super.oncreateoptionsmenu(menu);     }      @override      public boolean onoptionsitemselected(menuitem item) {             // handle presses on action bar items             switch (item.getitemid()) {             case r.id.action_search:             //  opensearch();                 return true;             case r.id.action_settings:             //  opensettings();                 return true;             default:                 return super.onoptionsitemselected(item);             } } 

this style.xml should ok:

<resources>      <!--         base application theme, dependent on api level. theme replaced         appbasetheme res/values-vxx/styles.xml on newer devices.     -->     <style name="appbasetheme" parent="theme.appcompat.light">         <!--             theme customizations available in newer api levels can go in             res/values-vxx/styles.xml, while customizations related             backward-compatibility can go here.         -->     </style>      <!-- application theme. -->     <style name="apptheme" parent="appbasetheme">         <!-- customizations not specific particular api-level can go here. -->     </style>  </resources> 

this screen don't see search action button screen

.

what else check? cannot find additional in web. following answers of stackoverflow did not me: can't add search button action bar in android developer tutorial

i had following error: styles.xml @ v14 looked following

<!--     base application theme api 14+. theme replaces     appbasetheme both res/values/styles.xml ,     res/values-v11/styles.xml on api 14+ devices. --> <style name="appbasetheme" parent="theme.appcompat.light.darkactionbar">     <!-- api 14 theme customizations can go here. --> </style> 

the search button not visible because action bar black , search icon not visible .

when changing

<!--     base application theme api 14+. theme replaces     appbasetheme both res/values/styles.xml ,     res/values-v11/styles.xml on api 14+ devices. --> <style name="appbasetheme" parent="theme.appcompat.light">     <!-- api 14 theme customizations can go here. --> </style> 

it becomes visible.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -