Android AppCompat ActionBar MenuItem view customization - android

Is there a way to change the appearance of action items inflated from menu.xml file? If so could you point me to the right direction. Thanks. If you need to know why do I need this, the main reason is that I dislike the default padding and the default selector

Well I figured this on my own.
To set custom MenuItem view use ActionProvided. In my case, I just extended ActionProvider class and overrode onCreateActionView method. What you'll do more, its up to you :)

Related

Moving options menu to another view

I am trying to display the options menu in another place but the ActionBar, is it is hidden.
I have no clue on how to do it nor I find any function to do such things.
I am using Theme.Light.NoTitleBar as theme/style, but still I'd like to have the menu somewhere else, be it a View or a Layout.
Does anyone have any clue?
You would need to use Android support library , which would enable you to use Action Bar in Android Version 11.0 and above. You would also require to use Theme.Holo.Light.DarkActionBar as your application theme to make action bar visible.
After you do this , you may create menu xml file ad inflate it in onCreateOptionsMenu() function , and you can then access Action Bar like this : getActionBar() in your activity.

Android Actionbar PopupMenu with Custom Item Layouts

I am working on an Android application where I have to design a menu which will populate from the action bar, like this:
I have tried my best but was not able to produce it using the Android controls.
The solutions I have tried are:
With Actionbar, add a menu item with a group with selectable="all", that produces the layout I need but when I click a checkbox for selecting it, the whole menu hides and selection is not done, moreover the menu icon in actionbar does not have the bottom right white arrow.
Tried creating a custom ActionProvider and added the menu items using class's OnPrepareSubMenu method but had the same issue.
I just need a push in the right direction and I can do the rest, suggestions are more than welcome.
Thank you :)
Use popupWindow.
In that you can make any custom layout and set it as content of your popupwindow and also you can specify an ANCHOR in your case it would be
R.id.your_menu_item
set a listener and listen the changes.

How to set drawables on actionbar of my android application

I'm developing an application in which I have to put drawables on top of the actionbar and have to update then from time to time. Here is a layout what I want it to look like.
I want to put a drawable as shown in the picture atttached(The green color drawable not the notification thing). Is that possible to achieve this kind of screen in android? If, so please guide me how to achieve this.
Any kind of help will be appreciated.
This is easy using a custom view. Let me explain you the steps briefly:
Create your custom view in the layout folder. For example, an ImageButton.
Set this view as the custom view of the action bar in your activity. You can do this by calling
getSupportActionBar().setCustomView(R.layout.your_custom_view);
(or getActionBar() instead of getSupportActionBar())
Call setDisplayOptions() with the ActionBar.DISPLAY_SHOW_HOME and ActionBar.DISPLAY_SHOW_CUSTOM options.
If you have other standard buttons in the action bar, inflate the menu.
You can finally set the OnClickListener for your custom view.
This worked for me, hope it helps you!
Create custom view
Use it as ActionView in ActionBar
In onCreateOptionsMenu get a reference to your view and update it when needed

How to imitate ActionBar menu?

Is possible create something like this without using ActionBar? I just need "button" which will rolling some items after click...
ActionBarSherlock might be useful in your case: http://actionbarsherlock.com/
A "dirty" method would be to link your button to an invisible Spinner, which will become visible as soon as the button is pressed. Then it's simply a case of binding the onSelect event of the spinner and theming it.

Show tab bar and listIn Actionbar at same time. (Android Honeycomb)

There is a situation in which I want to use Tab bar as well as List navigation, Both at same time in Action bar.
Documentation says 'we can put Actionbar in to list navigation mode or tabs navigation mode'.
Is there any way to use both at same time. Any pointers, help. Thank you in Advance.
Sorry, you can only have one or the other.
That being said, you can use android:actionLayout to convert an options menu item into a custom inflated layout in the action bar. You might be able to use the "tabs navigation mode" while putting your own Spinner to the right of the tabs this way. Personally, I would find this confusing as a user, but perhaps it will work for your use case.
a very late answer, but this is possible by a simple hack. You just have to replace (programatically) the view that is pointed by android.R.id.action_bar_title with a Spinner. I wrote a blog about it. Here's the link

Categories

Resources