Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Edittext in action bar in android?

Can we use an edit text in action bar? After reading lot of resources in Google i could not find how to create an edit text in action bar. Can anyone tell me how do i do it?

like image 262
Shruti Purushan Avatar asked Jul 26 '14 06:07

Shruti Purushan


2 Answers

You can set a custom View for the ActionBar like this:

getActionBar().setCustomView(R.layout.custom_actionbar);

You can then find Views from the custom View in the ActionBar like this:

View actionBarView = getActionBar().getCustomView();
EditText editText = (EditText) acitonBarView.findViewById(R.id.editText);

Or you can just directly set a View instance as custom View like this:

EditText editText = new EditText(context);
getActionBar().setCustomView(editText);
like image 158
Xaver Kapeller Avatar answered Sep 29 '22 20:09

Xaver Kapeller


Try this::

First url Second url

like image 29
vijay Avatar answered Sep 29 '22 19:09

vijay