android-menu

How do I set id for the new icon I set in onPrepareOptionsMenu

十年热恋 提交于 2019-12-08 06:03:58
问题 Hi I would like to set a item id for the new icon I set in OnPrepareOptionMenu. The new icon code is menu.getItem(0).setIcon(R.drawable.bluetooth); I want to set id for this new icon so that I can used it on the onOptionsItemSelected . Here is my Main Activity code boolean canAddItem = false; @Override public boolean onPrepareOptionsMenu(Menu menu) { if(canAddItem){ menu.getItem(0).setIcon(R.drawable.bluetooth); MenuItem mi =menu.add(0,MENU_ADD,Menu.NONE,R.string.bluetooth_on); mi.setIcon(R

How can I make a circular menu icon? Please see details

淺唱寂寞╮ 提交于 2019-12-07 23:03:17
问题 I'm developing a material design app & I want that the menu icon on toolbar should appear as a circular image instead of rectangular image . Here is the screenshot: Look at the menu icon , it is appearing as a rectangle , but I want it to be circular . How can I do this? 回答1: There is a library for android to make the photo circular .... https://github.com/hdodenhof/CircleImageView that's the link ....try it :) Edit: or you can use this library : https://github.com/Pkmmte/CircularImageView

Android Menu item font using LayoutInflaterCompat.setFactory

谁都会走 提交于 2019-12-07 16:36:01
问题 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() {

Forcing Overflow menu button on Android

安稳与你 提交于 2019-12-07 14:37:51
问题 I am developing an application for Android 4.0.3. I have multiple fragments and I have one menu item displayed on each of them. I want to have an overflow menu button that will have 2 menu items. How do I force the appearance of the overflow menu and add menu items to it ? I am adding menu items by calling the onCreateOptionsMenu function in each fragment. Any and all help would be appreciated. Thanks! 回答1: To force into the overflow menu do this: @Override public boolean onCreateOptionsMenu

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

无人久伴 提交于 2019-12-07 12:16:19
问题 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"

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

核能气质少年 提交于 2019-12-07 05:53:46
问题 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"/> 回答1: This attribute is introduced in API level 11. Check the min and target version of

How do I set id for the new icon I set in onPrepareOptionsMenu

时光总嘲笑我的痴心妄想 提交于 2019-12-06 16:39:23
Hi I would like to set a item id for the new icon I set in OnPrepareOptionMenu. The new icon code is menu.getItem(0).setIcon(R.drawable.bluetooth); I want to set id for this new icon so that I can used it on the onOptionsItemSelected . Here is my Main Activity code boolean canAddItem = false; @Override public boolean onPrepareOptionsMenu(Menu menu) { if(canAddItem){ menu.getItem(0).setIcon(R.drawable.bluetooth); MenuItem mi =menu.add(0,MENU_ADD,Menu.NONE,R.string.bluetooth_on); mi.setIcon(R.drawable.ic_bluetooth_searching_white_24dp); mi.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);

How can I make a circular menu icon? Please see details

会有一股神秘感。 提交于 2019-12-06 12:19:58
I'm developing a material design app & I want that the menu icon on toolbar should appear as a circular image instead of rectangular image . Here is the screenshot: Look at the menu icon , it is appearing as a rectangle , but I want it to be circular . How can I do this? There is a library for android to make the photo circular .... https://github.com/hdodenhof/CircleImageView that's the link ....try it :) Edit: or you can use this library : https://github.com/Pkmmte/CircularImageView You can use this websit to return the circle icon: Android Asset Studio And then include it in the project.

Android creating Bottom Bar Menu

孤人 提交于 2019-12-06 09:34:33
I want to have an static bottom menu bar exist through out the applications in every page visible at bottom all the time. I have designed the menu bar but i am confused whether i have to integrate the menu code with every layout xmls to make menu visible in every page and write the code in every activity class to perform functions on menu clicks. Or if there is any other way i can create a common bottom bar that lies with every page with writing the code of menu in a single activity class . Well the best way in my opinion , is to create a bottom bar xml file , and include it in every Activity

How to create custom option menu in android

牧云@^-^@ 提交于 2019-12-06 08:46:19
问题 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