Moving options menu to another view - android

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.

Related

Android - Action Bar Style

I want to show Action Bar like below.
I have already used this library clickhere
But it takes only two icons on Action Bar. If I add four items, then last two are shown me like menu. I want all in Action bar same as image above.
Is it possible? if yes, then HOW? Can I change Action Bar color or its default style available in Device?
Thanks in Advance.
I recommend you use this:
http://jgilfelt.github.com/android-actionbarstylegenerator/
to style your ActionBar.
If you want all the 4 icons to be there, just add this attribute to all the menu items:
android:showAsAction="always"
hello try this library
it sure help you And you may have to add you own logic to handle this in below 2.3 Android OS and above 3.0 Android OS.
there is many demo sample available like below :
There is no way you can be sure of the number of icons displayed in the action bar. There is a large varierty of Android devices out there and they all have different screen sizes. That's why you have to prioritize the actions available in a menu : the most important will be displayed as actions in the action bars and the others will be displayed in the "menu" : the action overflow.
You should think of actions in a functional way, not a graphical way.
With ref to Image that you attached you should decide which design pattern you want to use in your application, there are many UI patterns available for mobiles, tablets. The image you attached looks like Side Navigation UI pattern. It's better you decide which UI pattern perfect for your app.. then start implementing it with custom action bar libs (if you want action bar in less than Android 3.0 ver) or any other.

How to click on custom ActionbarSherlock views with Robotium

I am writing test cases for my app using Robotium. The app uses ActionbarSherlock for porting the Actionbar on versions prior to 4.0. However the ActionBar items always seem elusive to get hold of. I tried to use this project - https://github.com/atermenji/robotium-actionbarsherlock but didn't have much luck with custom actionbars. I tried the following code:
solo.clickOnVisibleActionbarItem(com.vtcreator.android360.R.id.notification_icon);
R.id.notification_icon is a button defined in the custom action bar layout.
Anyone with experience of both Robotium and ABS?
Since you have source code access anyway, you can choose to access the ActionBar item on a view level.
View actionbarItem1 = solo.getView(R.id.notification_icon);
solo.clickOnView(actionbarItem1);
In my current project which makes use of Action Bar to place Back Key and three action menu items as Image Buttons, following code worked fine -
// Selecting Back function button on Action Bar
// com.main.myapp is the package name of the main application which is under test.
ActionBarView actionBar = (ActionBarView)solo.getView(com.main.myapp.R.id.abs__action_bar);
ImageView backUpKey = (ImageView)actionBar.findViewById(com.main.myapp.R.id.abs__home);
solo.clickOnView(backUpKey);
// Click on Tools Icon on Action Bar Menu
solo.clickOnImageButton(2);
This is the better way to handle :
This Should work along with lib robotium-actionbarsherlock # https://github.com/atermenji/robotium-actionbarsherlock
if (Build.VERSION.SDK_INT < 11)
solo.clickOnActionBarHomeButtonCompat();
else
solo.clickOnActionBarHomeButton();

Creating Android Facebook-like menu on bottom bar

I'm using Galaxy tab and it's got a bar on bottom that appears all the time.
FB app shows a new item there that used as a menu button.
How can I declare my menu to be there like FB?
Thanks!
I guess they are still using the old options menu. You can achieve that effect by setting the target sdk to max 10. I wouldn't recommend that as the menu button hides information and is not the current way to go (I'd use an ActionBar)
You should definately look at the ActionBar. In addition to the tab navigation that is available, you have an option for a split action bar for top and bottom. ActionBar is part of Honeycomb (3.x), but if you want to support older versions, there is the ActionBarSherlock library.

Whether options menu at the bottom in Android can be made permanent?

Whether options menu at the bottom (Inflated menu) can be made permanent? The menu should be permanently inflated without the need for user to press the menu button?
whether it can be done?
whether it can be done?
No.
Besides, that menu is going away. Honeycomb and Ice Cream Sandwich are moving to the action bar pattern, where the options menu is integrated into the action bar as a drop-down menu and optional toolbar buttons.
If you want to give the user some always-visible set of actions, consider adding the action bar to your own applications. You can do this on pre-Honeycomb devices using third-party action bar implementations like ActionBarSherlock.
You can wrap your layout in a relativelayout and add buttons to the bottom. You can have it look similar too.
As Bill said you can add buttons in Relative layout and not create menu...if you need some code just tell me...
In which version you want the solution ,
in tab versions and 4.0 you can solve this problem as follows.
in manifest file add this attibute to application Tag android:uiOptions="splitActionBarWhenNarrow" so that your actionbar shows in the bottom. while your mobile is in portrait , in landscape it shows as usual on the top
and them add this flag to your menu item
MenuItem.SHOW_AS_ACTION_ALWAYS
check this link for more flags http://developer.android.com/reference/android/view/MenuItem.html i hope this will solve the issue

How to create a custom Pulldown in the Honeycomb ActionBar?

I would like to add a custom pulldown menu to the actionbar in my project similar to the one that can be found in the google books app (screen).
In this case it represents the complete table of contents of the book.
I tried to follow the guide from the developer site where there is an example with a SpinnerAdapter. But when i use a custom Layout (in my case a RelativeLayout with two TextViews in it) i get an Exception that saying "ArrayAdapter requires the resource ID to be a TextView". So i dismissed my idea with the pulldown but then i found the pulldown in the books app wich looks to me like they used a custom layout as well because it looks to me like two single TextViews in one Layout.
Could anybody please enlighten me if what i want to do is even possible and how?
To me, that looks like the options menu -- that's where options menu items not promoted to the action bar itself appear. Use onCreateOptionsMenu() and add whatever items you want to the Menu.
EDIT:
Sorry, the screenshot was a bit confusing. There are two possibilities that I can see:
This could be a submenu for that action bar item -- I haven't played with submenus and the action bar yet (though this reminds me that I need to do that...)
This could be a PopupMenu tied to a custom action bar View

Categories

Resources