android-menu

How can I focus on a collapsible action view EditText item in the action bar (when it is expanded) and force the soft keyboard to open?

跟風遠走 提交于 2019-11-30 08:12:31
I am using Jake Wharton's excellent ActionBarSherlock library and have a collapsible search action view. I want to popup the soft keyboard when the search action view is expanded. We can read a recommended way of doing this in a DialogFragment in the " Using DialogFragments " blog post by Google (altered a bit for readability). // Show soft keyboard automatically mEditText.requestFocus(); int mode = WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE; getDialog().getWindow().setSoftInputMode(mode); This does not seem to work when expanding and requesting focus on a collapsable EditText action

Enable/Disable ActionBar Menu Item

大兔子大兔子 提交于 2019-11-30 08:02:11
I have actionbar menuitems cancel and save. menu.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/saveButton" android:showAsAction="always" android:title="@string/save" android:visible="true"> </item> <item android:id="@+id/cancelButton" android:showAsAction="always" android:title="@string/cancel" android:visible="true"> </item> </menu> I want to disable save menuitem when activity is started. My activity code - @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub

How to programmatically trigger/click on a MenuItem in Android?

放肆的年华 提交于 2019-11-30 07:59:49
I have these menu items in my menu_main.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/tools" tools:context=".MainActivity"> <item android:id="@+id/action_restart" android:title="Restart" android:orderInCategory="1" /> <item android:id="@+id/action_clear" android:title="Clear" android:orderInCategory="2" /> <item android:id="@+id/action_update" android:title="Update" android:orderInCategory="3" /> <item android:id="@+id/action_about" android:title="About" android:orderInCategory="4

How to add submenu items to NavigationView programmatically instead of menu xml

纵饮孤独 提交于 2019-11-30 07:17:55
I'm trying to add submenu items to NavigationView programmatically . I'm able to add items into menu but not into submenu Adding items to menu works Menu menu = mNavigationView.getMenu(); menu.add(Menu.NONE, Menu.NONE, index, "Menu Item1"); But adding items to sub menu doesn't work Menu menu = mNavigationView.getMenu(); SubMenu subMenu = menu.addSubMenu("Sub menu title"); subMenu.add(Menu.NONE, Menu.NONE, index, "SubMenu Item1"); The trick to call BaseAdapter.notifyDataSetChanged on the underlying Adapter that contains the menu items. You could use reflection to grab the ListView or just loop

How to get dividers in NavigationView menu without titles?

柔情痞子 提交于 2019-11-30 05:37:24
I am using the new NavigationView to create my navigation drawer menu from XML. I need to place a divider between the section menu items, which switch between the sections of my app, and the settings and help & support links at the bottom. In all the examples I've seen, I see how this can be done by putting another <menu> within an <item> , but the <item> requires to have the android:title attribute, so the best I can do is make the title blank, which leaves an empty space before the settings and help & feedback. <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android

Android ActionBar compatibility: MenuItem.setActionView(View)

风流意气都作罢 提交于 2019-11-30 04:48:17
问题 I'm using the appcompat7 lib for ActionBar backwards compatibility. Now I have a MenuItem that I retrieve, and then want to set an ImageView myView as its icon. The way how to do it from API level 11 is: MenuItem menuItemRefresh = menu.findItem(R.id.refresh); menuItemRefresh.setActionView(myView); For API levels lower than 11 this doesn't work, the second line will show an error. Is there an option to do this in compatibility mode? 回答1: Look at MenuItemCompat : http://developer.android.com

Vertical sliding menu in Android

与世无争的帅哥 提交于 2019-11-30 04:13:36
Is there a vertical sliding menu available for android. I need something similar to Sliding menu of the Google Plus App BUT I need it to be able to slide vertically from bottom to top also. This UI Pattern is currently being referred to as Side Navigation and discussed in some detail here: http://www.androiduipatterns.com/2012/06/emerging-ui-pattern-side-navigation.html I think this is what you are looking for :) https://github.com/korovyansk/android-fb-like-slideout-navigation The side navigation isn't (yet) included in the Android SDK. A quick search in github does reveal one project that

How to make whatsapp type of animation for opening the menu from toolbar(actionbar)

£可爱£侵袭症+ 提交于 2019-11-30 01:27:05
Description: I recently updated whatsapp and noticed the animation for menu item clicked on toolbar. How to achieve this effect? Are there any opensource projects to achieve this? I have not posted any code because. I have no clue how they are doing it. Snapshot-1 : Before clicking the attachment button in menu Snapshot-2 : After clicking the attachment button in menu How to Achieve this? Seems like they "ported" lollipop animation in pre-L devices. The simplest way to do this is using libraries like Igvalle's Material-Animation (see #4). Its minSdk is 16, but I hope you can decrease it for 14

showAsAction=“ifRoom” doesn't show the item even when there is plenty of room

爷,独闯天下 提交于 2019-11-29 22:49:17
I am trying to get the ActionBar working properly on my app (and I'm using ActionBarSherlock to get a unified UI between Android 2.x and 4.x). I feel like android:showAsAction="ifRoom" is just a big, fat lie. Whenever I set an action to ifRoom it ALWAYS shows up in the overflow menu even if there is PLENTY of room. Here are two screenshots from the same emulator. The first shows the ActionBar with all options set to always and the second shows the ActionBar with the last two options set to ifRoom . As you can see, there was PLENTY of room when they were all shown in the always screenshot, so

How to add title in Navigation drawer layout?

不羁的心 提交于 2019-11-29 20:19:42
[UPDATE] I solve the problem by adding addHeaderView : protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTitle = mDrawerTitle = getTitle(); mPlanetTitles = getResources().getStringArray(R.array.planets_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); LayoutInflater inflater = getLayoutInflater(); ViewGroup mTop = (ViewGroup)inflater.inflate(R.layout.header_listview_menu, mDrawerList, false); mDrawerList.addHeaderView(mTop, null, false)