android-menu

Android : Change cart menu badge counter from Recycler Adapter

前提是你 提交于 2019-12-03 21:39:18
I am trying to develop e-commerce type of app in which user can add item to cart. But I am unable to update the cart badge counter from adapter. Here is screenshot of my app. I am using Recycler view inside fragment. And I am referring this below link for menu item count. https://mobikul.com/adding-badge-count-on-menu-items-like-cart-notification-etc/ My problem is I cannot access menu item from adapter. Here is my fragment code. PriceListFragment.java public class PriceListFragment extends Fragment { public ArrayList<Design> designList; private Single_DesignAdapter adapter; private

Trying to hide/disable entire menu (overflow) in fragment

一曲冷凌霜 提交于 2019-12-03 20:10:43
I have been unsuccessful in trying to hide or disable the overflow menu in one fragment . I have tried setting setHasOptionsMenu(false) with no success, and then I tried setHasOptionsMenu(true) and tried inflating with an empty menu like below. Both attempts do not work for me. How do I hide or disable the options/overflow menu in one fragment only?? Thanks in advance! Fragment @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // Inflate the

android getMenuInflater() in a fragment subclass - cannot resolve method

旧时模样 提交于 2019-12-03 16:25:13
问题 I am trying to inflate a menu in a class that inherits the Fragment class. Here is my OnCreateOptionsMenu() method - @Override public boolean OnCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.forecastfragment, menu) ; return true; } This raises the following error: Cannot resolve method 'getMenuInflater()' I tried : MenuInflater inflater = getActivity().getMenuInflater(); but then Android Studio highlights @Override in red and states: Method does not override method from its

Android align menu items to left in action bar

我的梦境 提交于 2019-12-03 16:12:55
问题 i have action bar in my application that displays menu items defined in my res/menu/activity_main.xml My menu items are aligned to right on action bar. I want them to be aligned to left. Only solutions i found for this used custom action bar, like this one: Positioning menu items to the left of the ActionBar in Honeycomb However, i dont want to create custom layout for my menu . I want to use default menu items generated from my res/menu/activity_main.xml . Is this possible? 回答1: Well, i was

Add a menu to an empty activity

旧街凉风 提交于 2019-12-03 11:48:22
问题 I have made an android application in Android Studio and would like to create a option menu on it. I created it as an empty activity and now realize I would have been better creating a blank activity to get the option menu. Is there anyway to create the option menu in a empty activity. If someone could point me to a tutorial that would be great this is my code so far for my menu. menu_menu <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com

menu inflating calls multiple times at fragment's onCreateOptionsMenu

倾然丶 夕夏残阳落幕 提交于 2019-12-03 10:36:51
I use Fragments and when I switch to nested Fragment, which implements public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) my menu inflates quantity of times when I get to that nested Fragment. How can I avoid this? I also implement constructor of Fragment with methods: setRetainInstance(true); setHasOptionsMenu(true); When I tried to implement siple solution as: @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // TODO Add your menu entries here if(!isInflated) { inflater.inflate(R.menu.contacts_archive_menu, menu); isInflated = true; } super

How do you remove an inflated menu/items from the new Lollipop Toolbar?

本小妞迷上赌 提交于 2019-12-03 10:29:22
问题 I include a v7 Toolbar in my layout. <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white" /> I'm inflating a menu into it with the following: mToolbar.inflateMenu(R.menu.options_add_contact); Now how do I know remove/reset it? I've tried a couple shots in the dark: inflating an empty menu mToolbar.inflateMenu(0) moolbar.setMenu(null, null) toolbar.setMenu(null, null) 回答1:

How to access views insde the actionLayout in menu

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 09:38:15
问题 I have three menu items which includes same app:actionLayout it has a textview, how can i access the textviews individually through code and set different text for all three textviews. activity_main_drawer.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <group android:checkableBehavior="single"> <item android:id="@+id/item_tracks" app:actionLayout="@layout/menu_text_layout" android

Fragments, with the same menu, on the same layout cause duplicated menuitem

大兔子大兔子 提交于 2019-12-03 09:19:51
问题 I have a layout which has 2 fragments. These fragments uses the same menu, because I have another layouts that has only one of these (used in small screen device). My problem is menu items of each fragments shows in the menu, and since they're from the same menu, they are duplicated to each others. I need to display only menu from one fragment, not both. Is there anyway I could archive this ? Or, probably better, create 2 different menu. One for the layouts that has one of these fragment

Light.DarkActionBar menu item text colour unchangeable?

断了今生、忘了曾经 提交于 2019-12-03 05:46:11
问题 The application I've been developing uses ActionBarSherlock, and the main theme inherits from Theme.Sherlock.Light.DarkActionBar. The design requires that the overflow menu popups have a dark coloured background and white text. This works fine for devices without a physical menu button, and the text appears white as intended. However, if the device DOES have a physical menu button, the text shown in the menu displayed remains black. My main theme contains <item name="android:panelBackground">