android-menu

BottomNavigationView Original icon color

人盡茶涼 提交于 2019-11-27 18:03:15
问题 I have my bottomNavigationView : And i added this class to prevent it from doing shiftingMode : public class BottomNavigationViewHelper { public static void disableShiftMode(BottomNavigationView view) { BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0); try { Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode"); shiftingMode.setAccessible(true); shiftingMode.setBoolean(menuView, false); shiftingMode.setAccessible(false); for (int i = 0; i

app:showAsAction vs android:showAsAction

老子叫甜甜 提交于 2019-11-27 15:59:17
问题 I am building an Android app and want to have a button always visible on the actionBar. I followed this guide and others, but none of them seem to solve my problem (although they are very close I guess...). I have the package "app" and use app:showAsAction="always" . No error is shown, but no button on the bar as well. When I change it to android:showAsAction="always" the button appears on the bar, but AndroidStudio tells me I should go for "app:showAsAction with appCompat...". I have a

openOptionsMenu function not working in ICS?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 15:29:37
Im using action bar compability library. Im trying to open the options menu from a button with openOptionsMenu() function but it does nothing. Menu shows as usual when pressing the menu key on my phone. What is wrong here? public class ReadActivity extends ActionBarActivity { ... @Override public boolean onCreateOptionsMenu(Menu menu) { boolean value; MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.read, menu); value = super.onCreateOptionsMenu(menu); if (Helper.SupportsNewApi()) { getActionBar().hide(); } else { ((View) ((LinearLayout) findViewById(R.id.actionbar

How do I get a copy of the Android overflow menu icon? [closed]

不打扰是莪最后的温柔 提交于 2019-11-27 14:00:42
How do I get a copy of Android's overflow menu icon to use in a custom menu. Can somebody please provide a link to download the overflow menu icon? http://developer.android.com Once you have downloaded the SDK, you will find your images in: $ANDROID_SDK/platforms/$PLATFORM/data/res/$DRAWABLE/ic_menu_moreoverflow* where: $ANDROID_SDK is wherever you installed your SDK $PLATFORM is some platform directory (e.g., android-17 ) $DRAWABLE is some major drawable directory (e.g., drawable-hdpi ) There are different versions of the image for light and dark themes and whether or not the button has the

How to display and set click event on Back Arrow on Toolbar?

末鹿安然 提交于 2019-11-27 13:05:58
How can I set back arrow in Android toolbar and also apply click listener? Pratik Tank First make one toolbar.xml <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" android:background="@color/colorPrimary" local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

How to add menu button without action bar?

送分小仙女□ 提交于 2019-11-27 12:20:50
问题 I'd like to add a menu button to the right top corner of my app and without action bar, like it is in Google Fit app on the screenshot below. Can anyone help me? 回答1: You can simply use PopupMenu , for example add the following to a button when clicked: public void showPopup(View v) { PopupMenu popup = new PopupMenu(this, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.actions, popup.getMenu()); popup.show(); } For more info, read Creating a Popup Menu : http:/

Android Checkable Menu Item

£可爱£侵袭症+ 提交于 2019-11-27 11:25:27
I have the following menu layout in my Android app: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/item1" android:titleCondensed="Options" android:title="Highlight Options" android:icon="@android:drawable/ic_menu_preferences" /> <item android:id="@+id/item2" android:titleCondensed="Persist" android:title="Persist" android:icon="@android:drawable/ic_menu_preferences" android:checkable="true" /> </menu> My problem is that the second menu item doesn't appear to be "checkable" when I run my app in the Android emulator

Setting PopupMenu menu items programmatically

久未见 提交于 2019-11-27 10:40:26
问题 I have a PopupMenu and I know the usual way to associate a menu to it is to use popup.getMenuInflater().inflate(R.menu.my_menu, popup.getMenu()); or something of the like. My problem is, I have an array of items that I want in the menu and I need to be able to change them programmatically in Java. How can I do this? 回答1: Just figured it out; for anyone who runs into this same problem you just do: popup.getMenu().add(groupId, itemId, order, title); for each MenuItem you want to add. 回答2: Just

actionlayout on menuitem does nothing

痞子三分冷 提交于 2019-11-27 07:22:22
i am setting an actionLayout on a menu item and setting background color and image, but it's not respected. in my activity, i have: getMenuInflater().inflate(R.menu.submit_action, menu); my submit_action is: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_submit" android:actionLayout="@layout/check" app:showAsAction="always" /> </menu> my check layout is <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/actionButtonStyle" android:layout_width="fill

Add toggle button to the menu to stop and start service

核能气质少年 提交于 2019-11-27 06:59:00
问题 I am trying to enable the user to stops and starts service which I am implementing from the Menu where the text is will be changed when he clicks it so I want to add ToggleButton as option in the menu tool but nothing is being display in my case now. How can I fix it? AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <ToggleButton android:id="@+id/toggle" android:layout_width="wrap_content" android:layout_height="wrap