android-menu

How to display menu item Icons on Android 9 in Floating Action Mode

亡梦爱人 提交于 2019-12-10 15:57:08
问题 I have an Android menu XML that resembles this:- <item android:id="@+id/action_share" android:orderInCategory="100" android:icon="@drawable/ic_social_share" app:showAsAction="always" android:title="" /> <item android:id="@+id/action_something_else" android:orderInCategory="200" android:icon="@drawable/ic_airplanemode_active_black_24dp" app:showAsAction="always" android:title="" /> My Android code resembles this:- private void startActionMode() { startActionMode(new android.view.ActionMode

How to change the menu in Android programmatically

痴心易碎 提交于 2019-12-10 15:45:49
问题 I have two different menu layouts. I want to change the inflated menu on runtime when a button is clicked. Initially the menu is set to @menu/navigation . I want it to change to @menu/navigation2 when button is clicked. activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width

Ionic/Cordova menubutton event not called

☆樱花仙子☆ 提交于 2019-12-10 13:07:17
问题 I am trying to monitor the Menu Button on Android (4.4.2 - Samsung S3), but the Ionic event (nor the underlying Cordova event) is not firing: $ionicPlatform.on("menubutton", function () { // do our stuff here (never gets called) }); Has anyone been able to make this work? Running Ionic platform 1.0.0, and all other events are firing as expected. 回答1: The docs are missing a line. document.addEventListener("deviceready", function() { ... navigator.app.overrideButton("menubutton", true); // <--

How to override “Copy”, “Share” and “Select All” options while selecting a text in a TextView

爱⌒轻易说出口 提交于 2019-12-10 12:14:10
问题 I have a TextView where a user is able to select a text. By default the following options appear: "Copy", "Share" and "Select All". I need to override them with custom options. But I can't find how to do that. I went through the documentation and this nice article but no lack. The article explains how to extend the menu when a user presses three-dots-button which is not what I need. Question: How can I override default "Copy", "Share" and "Select All" options in text section menu? Here is how

How to get view reference from menu item?

妖精的绣舞 提交于 2019-12-09 18:48:13
问题 Iam trying to get a menu item's reference but i just cant. This whole thing is inside a fragment. Menu: boat_accept_menu.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" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.toolbar.MainActivity" > <item android:id="@+id/done_boat_select" android:title="@string/done_C" app:showAsAction="always"/> </menu> You can

Bottom navigation view with custom item (actionLayout)

浪尽此生 提交于 2019-12-09 09:45:21
问题 I would like to add a custom item in the new BottomNavigationView . There are plenty of tutorial of adding a custom view with the normal navigation view but I can't find anything regarding the bottom one. This is my view <android.support.design.widget.BottomNavigationView android:id="@+id/navigation_view" android:layout_width="match_parent" android:layout_height="wrap_content" app:menu="@menu/menu_main" /> And this is the menu <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http:/

menu inflating calls multiple times at fragment's onCreateOptionsMenu

限于喜欢 提交于 2019-12-09 08:17:28
问题 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(

how to center icons in toolbar in android studio

╄→尐↘猪︶ㄣ 提交于 2019-12-09 05:22:11
问题 I asked a similar question here... I got some tutorials in the answers. But this question is diffrenet. because none of that method do not works in my project. I want center all icons in toolbar I test all availabe ways ...but always icons are floating in left. I want centering icons (I prefer left icon floats left and right icon floats right and other icons floats center) Activity.Main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas

Android Menu not showing up

家住魔仙堡 提交于 2019-12-08 07:36:26
问题 Im trying to get a custom menu to show when the menu button is clicked on my phone. Its not showing at all. I have a register icon caled register.png in this folder /res/drawable. I have my my_menu.xml in a folder called /res/menu. Did I lay out my folders wrong or is there something wrong in my code below. I renamed menu.xml to my_menu.xml I changed my code and now im getting these errors: [2012-04-07 07:50:43 - HelloWebView] W/ResourceType( 1560): Bad XML block: no root element node found

Hide Actionbar, Show Options Menu

时光总嘲笑我的痴心妄想 提交于 2019-12-08 07:28:53
问题 I have a non-market app that was built to run on a specific device. Originally, this was on a device running 2.2, but now the app is targeting a specific device on 3.1 and I am adding in support for the Action Bar . One of the apps Activities is required to be full-screen and have hidden the status bar and the Action Bar. This is achieved using the following in the manifest: <activity android:name=".activity.EditorActivity" android:label="@string/activity_edit" android:theme="@style/Canvas">