android i want to add searchview in actionbar but not got it -


i have layout in on title bar have option button , button work fine want add searchview in action bar dont know how new in android please me solve problem.

this activity code.

    public class thrd extends actionbaractivity {     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_thrd);         getsupportactionbar().settitle("3rd page");         getsupportactionbar().setdisplayhomeasupenabled(true);         colordrawable colordrawable = new colordrawable(color.parsecolor("#20a780"));         getsupportactionbar().setbackgrounddrawable(colordrawable);     }     @override     public boolean oncreateoptionsmenu(menu menu) {         menuinflater inflater = getmenuinflater();         inflater.inflate(r.menu.main_activity_actions, menu);         return true;     }     @override     public boolean onoptionsitemselected(menuitem item) {         switch (item.getitemid()) {              case r.id.action_exit:                 openexit();                 return true;             default:                 return super.onoptionsitemselected(item);     } }     private void openexit() {      } } 

this manu res file

<?xml version="1.0" encoding="utf-8"?> 

<!-- settings, should in overflow --> <item android:id="@+id/action_exit"     android:title="@string/action_exit"     android:showasaction="never" /> 

this string.xml file

<resources> <string name="app_name">qdas</string>  <string name="hello_world">hello world!</string> <string name="action_exit">exit</string>  <string name="title_activity_secnd">secnd</string> <string name="title_activity_thrd">thrd</string>  <string name="action_settings">settings</string> 

i have title bar enter image description here

look @ android developer shows step step how add search functionality.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -