Tag: android-menu

How can I force the onPrepareOptionsMenu method to fire?

In my activity’s onCreateOptionsMenu method, I am simply inflating my menu layout file and attaching it. I want to show/hide some menu items based on a value a of a global variable, I do this in the onPrepareOptionsMenu method. I’ve read that this is the correct place to do it. My onPrepareOptionsMenu method doesn’t always […]

Different menu for different tabs in tab+swipe application for android project

I am a beginner to android applications and java, basically I am a PHP developer. I’ve a project for a tab+swipe application, Reseller.java package com.idevoc.onsitereseller; import java.util.ArrayList; import android.app.ActionBar; import android.app.ActionBar.Tab; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.ViewPager; import android.view.Menu; import android.view.MenuInflater; public class Reseller extends […]

Android ActionBar compatibility: MenuItem.setActionView(View)

I’m using the appcompat7 lib for ActionBar backwards compatibility. Now I have a MenuItem that I retrieve, and then want to set an ImageView myView as its icon. The way how to do it from API level 11 is: MenuItem menuItemRefresh = menu.findItem(R.id.refresh); menuItemRefresh.setActionView(myView); For API levels lower than 11 this doesn’t work, the second […]

How to change menu theme in Android

My android application uses the following style: <style name=”AppTheme” parent=”android:style/Theme.Holo” ></style> It is assigned for the whole application in the AndroidManifest.xml file : <application android:theme=”@style/AppTheme” […] Using this style, menus look like this : However, if I use the light theme instead : <style name=”AppTheme” parent=”android:style/Theme.Light” ></style> Menus will look like this : My question […]

Android handling key up event while menu is visible

Here is my problem. I override volume down key for my application to do some specific task while it’s pressed for a long time, it works fine normally. I can intercept key down and key up events for that. The key listener events are written in particular custom component and not in activity where this […]

Android Different Menu Resources

Doe’s Android support multiple menu folder (e.g. like /drawable-hdpi and /drawable-mdpi)? If so what types are supported (land, xhdpi, swXXXdp)? P.S. Sorry for such a goofy question… Edit 1: For example I have different layouts. Depending on that I can have different menu resources, no? As a start it would be nice to have sooch […]

ActionBar capacity/overflow not changing on orientation change

I have an app using the ActionBar, where I handle orientation changes myself: android:configChanges=”keyboard|keyboardHidden|orientation|screenSize” …and the menu should fit in the ActionBar without overflow in landscape, but not in portrait: <?xml version=”1.0″ encoding=”utf-8″?> <menu xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:title=”@string/Game” android:id=”@+id/game” android:icon=”@android:drawable/ic_menu_manage” android:showAsAction=”ifRoom|withText”/> <item android:title=”@string/Type” android:id=”@+id/type” android:icon=”@android:drawable/ic_menu_edit” android:showAsAction=”ifRoom|withText”/> <item android:title=”@string/Other” android:id=”@+id/other” android:icon=”@android:drawable/ic_menu_gallery” android:showAsAction=”ifRoom|withText”/> <item android:title=”@string/Solve” android:id=”@+id/solve” android:icon=”@android:drawable/ic_menu_directions” android:showAsAction=”ifRoom|withText”/> […]

Android ActionBar menu with vertical (rotated) text items based on Custom Action Provider

I am adding a menu to an action bar item. The menu will contain vertical text for each item. What the menu contains is not important. I basically just want to create my own view that will pop up when I press an action bar item. So for the purposes of this question, you could […]

Modify style of Android items in the ActionBar

How can I modify the style of the items on the Action bar of an Android Application? I tryed the following: <item name=”android:actionBarStyle”>@style/ActionBar.Light</item> <style name=”ActionBar.Light” parent=”@style/ActionBar”> <item name=”android:background”>@color/black</item> <item name=”android:actionMenuTextColor”>#FF00FF</item> </style> The background of the Action bar I was able to modify, but not the text Colors of the items in the Action bar. How […]

options menu locks up on galaxy s4

My app uses the old-style options menu. Currently we target API 9. On the Galaxy S4 I notice the following behavior: User taps on the menu button. Menu is displayed as expected. User taps on “more” to access the overflow section. Overflow section is displayed as expected. User taps the back button to return to […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.