popupmenu

Show popup menu on `ActionBar` item click

人走茶凉 提交于 2019-11-27 12:01:15
I have an ActionBar with an action item on it. After clicking on the action item, I want to show a popup menu. I implemented this method, but I want to anchor it to the action item or to the ActionBar , not to any view from layout. How to get some kind of view to anchor it from MenuItem ? public boolean onOptionsItemSelected(MenuItem item) { PopupMenu popupMenu = new PopupMenu(this, ??????); // What view goes here? popupMenu.inflate(R.menu.counters_overflow); popupMenu.show(); // ... return true; } So finally I found solution. When you want to anchor popupmenu to ActionItem in ActionBar you

How to prevent popup menu from closing on checkbox click

青春壹個敷衍的年華 提交于 2019-11-27 06:04:31
问题 I search a lot on net but there is nothing about preventing popup menu from closing. Whenever i click on checkbox item or any other popup menu item, popup menu dismiss itself. How can i prevent it from dismissing when user check/uncheck checkbox in popup menu. I'm showing popup menu on actionbar-menu item's click event. //main_menu.xml <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

Implement pop up Menu with margin

一世执手 提交于 2019-11-27 03:53:48
问题 I am using the default pop menu and expecting the behavior of the same. Everything is working fine. What my concern is regarding the rendering of pop up menu. My pop up menu sticks to the right of the screen. I want the behavior as used by Youtube app for android. I am mainly not able to provide right margin to my pop up menu. Please help. I have tried providing Gravity to PopUp Menu. But Pop Up Menu sticks to the Right of screen. PopupMenu popupMenu = new PopupMenu(mContext, anchor, Gravity

Custom PopupMenu (layout)

心已入冬 提交于 2019-11-27 02:54:09
问题 I'm trying to upgrade my PopupMenu so it would come with icons and custom styles. I have created a new layout for it <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"> <RelativeLayout android:id="@+id/layout_sharea" android:background="@drawable/share" android:paddingLeft="10.0dip" android:paddingRight="10.0dip" android:layout_width="wrap_content" android

The best way to create drop down menu in android 2.x like in ICS

无人久伴 提交于 2019-11-27 01:53:21
问题 I want to create button with drop down menu, like overflow menu button in ActionBar on ICS. I have problem because PopupMenu there isn't in android 2.x. The second way using Spinner but it's not for me, because Spinner always show the first item on my custom background or my selected item. How can I acheive it? In general, I want ContextMenu but little and on position clicked view. Thanks. It looks like this : 回答1: If your purpose is to recreate an action bar, you could take a look at the

android popup menu text color (AppCompat)

时光毁灭记忆、已成空白 提交于 2019-11-26 17:00:01
问题 I need to change text color of a popuo menu but I don't find any way for do this, I can change background of popmenu but not the text, I edit the style.xml in this way: <style name="AppBaseTheme" parent="Theme.AppCompat.Light"> <!-- API 14 theme customizations can go here. --> <item name="popupMenuStyle">@style/MyPopupMenu</item> <item name="android:textAppearanceLargePopupMenu">@style/myPopupMenuTextAppearanceLarge</item> <item name="android:textAppearanceSmallPopupMenu">@style

Show popup menu on `ActionBar` item click

谁说胖子不能爱 提交于 2019-11-26 15:51:49
问题 I have an ActionBar with an action item on it. After clicking on the action item, I want to show a popup menu. I implemented this method, but I want to anchor it to the action item or to the ActionBar , not to any view from layout. How to get some kind of view to anchor it from MenuItem ? public boolean onOptionsItemSelected(MenuItem item) { PopupMenu popupMenu = new PopupMenu(this, ??????); // What view goes here? popupMenu.inflate(R.menu.counters_overflow); popupMenu.show(); // ... return

Get context of PopupMenu like ContextMenu

那年仲夏 提交于 2019-11-26 15:29:57
So my ExpandableListView has group rows that are defined like : group_row.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/GroupName" style="@style/ListViewRowStyle" android:paddingLeft="40dp" android:textSize="18sp" > </TextView> <ImageView android:id="@+id/Menu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginTop="10dp" android

Get context of PopupMenu like ContextMenu

别来无恙 提交于 2019-11-26 05:58:45
问题 So my ExpandableListView has group rows that are defined like : group_row.xml <?xml version=\"1.0\" encoding=\"utf-8\"?> <RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\" > <TextView android:id=\"@+id/GroupName\" style=\"@style/ListViewRowStyle\" android:paddingLeft=\"40dp\" android:textSize=\"18sp\" > </TextView> <ImageView android:id=\"@+id/Menu\" android:layout_width=\"wrap_content\"

Android custom dropdown/popup menu

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 04:35:24
问题 How do I do a custom dropdown/popup menu anchored to a button? I need it to work like the popup menu (anchored to a view), and do something when I click an item from the menu. How do I add items to the menu by code, keeping menu\'s height and make it scrollable if there are more than 5 items. I don\'t need to add any images, just text. 回答1: To create popup menu in android. activity_main.xml It contains only one button. File: activity_main.xml <RelativeLayout xmlns:android="http://schemas