android-actionbar

android: menu item click event from fragment

独自空忆成欢 提交于 2019-12-05 21:41:58
I have an application with actionbar. And there is menu inflated by the mainactivity. I want to intercept the click event inside the fragment but I don't know how? Can you help me please? MainActivity @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.home, menu); } home.xml <menu> <item android:id="@+id/action_refresh" android:title="@string/menu_refresh"/> </menu> And I want to refresh the list in the fragment If you want to capture the click on your item, implement public boolean onOptionsItemSelected(MenuItem item) And then: If your activity includes

How to fully mimic Action item view in the toolbar, for a customized one?

安稳与你 提交于 2019-12-05 21:01:53
Background I have an action item that's not quite standard. It has its own layout, because I've failed to create a nice Drawable for it (written about it here ). Basically, it's just a TextView with a background that wraps its short text that it shows. The problem Sadly I can't find a way of fully mimic it to look like normal ones: The ripple effect (and probably the simple clicking effect on older versions too) doesn't have the same color and size. There isn't a toast for when I long click on it Maybe other things I haven't noticed? Here are screenshots to demonstrate the differences: The new

Galaxy S4 SupportActionBar covers whole screen in ActionMode

北城以北 提交于 2019-12-05 20:58:44
The Samsung Galaxy S4 shows a very weird behavior when going into ACtionMode on my app which is using SupportActionBar from Support-v7. Has anyone an idea how to fix this? I guess the issue comes from Samsung custom Android-Rom. I solved this changing the parent of my custom actionmode theme from: <style name="MyApp.Widget.ActionMode" parent="@style/Widget.AppCompat.ActionMode"> to: <style name="Apo.Widget.ActionMode" parent="@style/Widget.AppCompat.Light.ActionMode.Inverse"> For some reason those themes don't seem valid in the latest AppCompat libraries (I tried Widget.AppCompat.ActionMode

How can I dismiss the Navigation Drawer to use the Back-home-icon button?

梦想的初衷 提交于 2019-12-05 20:56:29
问题 I'm using the action bar with search bar too, and I need to use the ActionBar ico like a Back button: But I'm using the navigation drawer too... How can I dismiss/hide/disable the Navigation Drawer menu to use the back button? My ActionBar code: @Override public boolean onCreateOptionsMenu(Menu menu){ MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); this.getSupportActionBar().setDisplayShowCustomEnabled(true); this.getSupportActionBar()

How to remove Application icon from Action Bar in Android?

孤人 提交于 2019-12-05 20:34:51
I am using Action bar with Tabs. I want to hide app icon from action bar. I use the below code, but action bar is showing below Tabs. Both are not useful for me. Any one help me! actionBar.setDisplayUseLogoEnabled(false); and actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayUseLogoEnabled(false); should do it. add actionBar.setDisplayShowTitleEnabled(false) 来源: https://stackoverflow.com/questions/13626216/how-to-remove-application-icon-from-action-bar-in-android

Android: Icons don't appear in Action Bar

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 20:30:54
I'm following the google tutorial for action bars but the icons don't appear on it, this is the menu xml file: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:yourapp="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/action_refresh" android:icon="@drawable/ic_action_refresh" android:title="refresh" android:showAsAction="ifRoom"/> <item android:id="@+id/action_settings" android:icon="@drawable/ic_action_settings" android:title="settings" android:showAsAction="ifRoom"/> <item android:id="@+id/action_compose" android:icon="@drawable/ic_action_new" android

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

Navigation Drawer and with Activity in Android

你。 提交于 2019-12-05 19:55:47
I am trying out the navigation drawer (slide menu) given in this tutorial. The difference with above link and mine is that instead of calling fragments I am trying to call the activity. When the app opens I am not able to see the Navigation drawer menu I can see only the action bar with HOME activity opened. Here is the code that I changed: (Is it necessary to have a fragment or can I use activity for my first screen in Navigation Drawer?) mTitle = mDrawerTitle = getTitle(); navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items); navMenuIcons = getResources().obtainTypedArray

best way to show the three dot menu item in action bar without using “a hack” method [closed]

风格不统一 提交于 2019-12-05 19:54:04
I am a little confused. I want to show the remaining items of the action bar inside the three dot item. But i always lose it when the number of items increases ! after googling a little, i found this "useful" method : ASMUIRTI ANSWER private void getOverflowMenu() { try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if(menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { e.printStackTrace(); } } I tested it and that work as i

Removing Extra Space in Custom ActionBar

巧了我就是萌 提交于 2019-12-05 18:17:34
My issue concerns using fully custom ActionBar views (as it's necessary for how my customer wants the ActionBar to work). I've removed the logo, title, and everything else possible. However, the custom view for the ActionBar will not extend all the way across the screen. I've tried the following (as a quick overview): Dynamically removing aspects of the ActionBar (snippet below) Removing the Options Menu in its entirety Specifying in the Style/Theme to remove everything from the ActionBar Here is a screenshot of my issue: Here is the style: (as a side note, I originally kept the native