android-menu

How to implement a badge counter on android hamburger menu icon [duplicate]

感情迁移 提交于 2019-12-06 07:43:36
问题 This question already has answers here : Add new item count to icon on button - Android (5 answers) Closed 3 years ago . I am trying to implement a counter badge on the hamburger menu icon (i.e. not the other menu icons). Similar to the eBay app. as in.. Has anyone looked into this? Trying to figure out the cleanest way possible. 回答1: its pretty simple to do with the Toolbar Widget you could follow below example to achieve that: first create an Oval shape <shape xmlns:android="http://schemas

Push icons away when expandig searchview in android toolbar

﹥>﹥吖頭↗ 提交于 2019-12-06 03:57:40
问题 I'm facing this particular behaviour and I don't know how to fix it.. In my activity I have this toolbar: And when you click on the search icon it expands and pushes the other icon to out of the view. I want to know how could I keep the icon on the right and reduce the search view space. This is my menu layout: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_search" android:title="@string

Get Current Selected Item of Navigation Drawer in Android

白昼怎懂夜的黑 提交于 2019-12-06 02:46:35
问题 How can i get Current selected item of navigation drawer? My menu is stored in drawer_menu.xml navigationView = (NavigationView) findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.change_sec: Intent intent_sec = new Intent(MainActivity.this, ClassDataProvider.class); startActivityForResult(intent_sec,

Spinner as MenuItem not initialized by findViewById

你。 提交于 2019-12-06 00:26:52
I have a spinner on my actionbar. It is a menuitem (not a navigation mode). It gives me back a nullpointerexception on the lines where i call a method from spinnerNumber. I think i'm doing something wrong with the xml or maybe i shouldn't initialize it on OnCreateOptionMenu (but i think that calling it on OnCreate, when the menu xml isn't still inflated, is not correct either). act_main.xml: <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/numberSpinner" android:actionLayout="@layout/spin_number" android:showAsAction="always"> </item> <item android:id="

how to show menu item under overflow icon in android api 8+

此生再无相见时 提交于 2019-12-05 20:16:09
How I can force menu item to show under overflow icon. I am providing app support from api level 8 and above. for now it is showing as actionview . My menuLayout is as follows. //main.xml <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/action_menu_setting" android:title="@string/menuItemSetting" app:showAsAction="ifRoom"/> <item android:id="@+id/action_signout" android:title="@string/menuItemLogout" app:showAsAction="ifRoom"/> </menu> in Java class @Override public boolean onCreateOptionsMenu(Menu

Android Menu item font using LayoutInflaterCompat.setFactory

别来无恙 提交于 2019-12-05 20:06:52
I'm trying to change font of Menu items. According to this answer , I'm using LayoutInflaterCompat.setFactory (support library 22.1.1 is used in my project). My code looks like this: @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_income_mail, menu); mFilterMenu = menu.getItem(1).getSubMenu(); final LayoutInflater inflaterCopy = getLayoutInflater().cloneInContext(this); LayoutInflaterCompat.setFactory(inflaterCopy, new LayoutInflaterFactory() { @Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { //

Navigation Drawer menu items selected within different groups

孤者浪人 提交于 2019-12-05 12:39:17
问题 I have a working Navigation Drawer and having some issues with menuItem.setChecked(true); when using groups and headers within the menu. It's not highlighting menu items as expected. Here is my XML: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context=".ActivityMap"> <group android:checkableBehavior="single"> <item android:id="@+id/nav_welcome" android:icon="@drawable/abc_btn_check_to_on_mtrl_000" android:title="Welcome"

error:no resource identifier found for attribute“showAsAction” in package android

不打扰是莪最后的温柔 提交于 2019-12-05 10:47:38
I've been working on an Android project and encountered an error which I'm unable to solve for quite a while. Here is the error which says error:no resource identifier found for attribute"showAsAction" in package android and the error is in following file login_.xml <item android:id="@+id/action_settings" android:orderInCategory="100" android:showAsAction="never" android:title="@string/action_settings"/> This attribute is introduced in API level 11. Check the min and target version of your app in Manifest file. Dhanesh "ShowAsAction" attribute is introduced in api 11. Change the minSdkVersion

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

你离开我真会死。 提交于 2019-12-05 02:16:48
问题 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

How to create custom option menu in android

拈花ヽ惹草 提交于 2019-12-04 12:41:32
I am creating an option menu. it has three option HOME, EMAIL, VISIT. All three options coming at the same row. i have to show HOME option above and rest two below to Home Option(according to attached Screen Shot). Any Ideas?? Thanks. Here is my XML file. <menu android:id="@+id/new_game" android:icon="@drawable/red_no_bg" android:title="Home" /> <item android:id="@+id/email" android:icon="@drawable/red_no_bg" android:title="Email" /> <item android:id="@+id/help" android:icon="@drawable/red_no_bg" android:title="Visit Microsite" /> </menu> Here is my code. @Override public boolean