I am using actionbarsherlock and I want to use an Edit Text and a Button in the action bar. I I have gone through many documents and posts but haven't found a solution yet.
How do I add an Edit Text in the Android action bar?
Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button. In general an ActionBar consists of the following four components: App Icon: App branding logo or icon will be displayed here.
Putting a regular Button
in the action bar will look fairly awful, IMHO.
That being said, you can use android:actionLayout
on your <item>
element in your menu XML resource. This should point to the name of a layout XML resource. This resource will be inflated into the action bar. You can get the widgets by calling getActionView()
on the MenuItem
object corresponding to this <item>
element.
Here is a sample project demonstrating this. Here is the documentation on this technique.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With