android-actionbar

Adding a button to the ActionBar with ActionBarSherlock

早过忘川 提交于 2019-12-17 18:34:58
问题 I have been trying to add a button to the SherlockActionBar but I can't get it working. This is the code that I have: @Override public boolean onCreateOptionsMenu(Menu menu) { android.view.MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, (android.view.Menu) menu); return super.onCreateOptionsMenu(menu); } This is my menu.xml code: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/save_button"

How to show selected fragment in action bar tab

北城以北 提交于 2019-12-17 18:30:57
问题 I am facing one issue regarding tab swipe. My project is built on Android 3.2. I am implementing tab swipe using support library 4.0 (android-support-v4.jar). Everything implemented is working fine but when I deploy my app to an ICS device, then in portrait mode I am getting a spinner in action bar for tab selection. In portrait mode, the tab selection is not changing when swipe is done although content is changing, and everything is working fine in landscape mode. final ActionBar actionBar =

SearchView taking all the space in the new ActionBarCompat

爷,独闯天下 提交于 2019-12-17 18:28:52
问题 I switched from ActionBarSherlock to ActionBarCompat (support library v7). After some adjustments, almost everything is working fine by now. But I'm in trouble with the SearchView in the ActionBar. When it's expanded (actually, It's always expanded in my Activity), it takes up all the space and doesn't respect the space of other Action Items that are set to show always (showAsAction="always"). To simulate the problem, use this: <menu xmlns:android="http://schemas.android.com/apk/res/android"

ActionBar with navigation tabs changes height with screen orientation

ぐ巨炮叔叔 提交于 2019-12-17 18:28:02
问题 My goal is to increase the ActionBar height for portrait mode. I currently set android:actionBarSize in my Themes.xml. <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="DayTheme" parent="android:style/Theme.Holo.Light"> <item name="android:actionBarSize">@dimen/actionBarHeight</item> <item name="android:actionBarTabTextStyle">@style/tab_indicator_text_dark</item> </style> <style name="NightTheme" parent="android:style

InflateException: Couldn't resolve menu item onClick handler

99封情书 提交于 2019-12-17 18:27:57
问题 I asked this question 6 years ago. In the meantime Android development best practices have changed, and I have become a better developer. Since then, I have realized that using the onClick XML attribute is a bad practice, and have removed it from any code base I work on. All of my click handlers are now defined in the code of the app, not the XML layouts! My reasons for never using onClick are it is easy to make a mistake in the value of the onClick XML attribute, which will then result in a

How to combine Navigation Drawer and Spinner [like in Google+ App]

两盒软妹~` 提交于 2019-12-17 18:24:31
问题 I need your advice. In Google+ App for Android, there are two elements, that I don't know how to put together. One is "Navigation Drawer" and second is "Action Bar Navigation Spinner". Do you know how these two elements put together? Thank you very much for your advice! P.S. I know, I'm lame :) (and I apologize for my English) 回答1: Add the spinner to the NavigationBar. The basic procedure to enable drop-down navigation is: 1.Create a SpinnerAdapter that provides the list of selectable items

Auto Collapse ActionBar SearchView on Soft Keyboard close

可紊 提交于 2019-12-17 17:41:50
问题 I am currently using an ActionBar menu item to display a SearchView in the action bar. When the search menu item is expanded the soft keyboard is displayed which is what I want. Now, when the user presses the back button to close the soft keyboard, I would also like to collapse the SearchView in the action bar. I have tried implementing the following listeners OnKeyListener and OnFocusChangeListener on the MenuItem and the ActionView. I have also tried using OnBackPressed() in the Activity.

Auto Collapse ActionBar SearchView on Soft Keyboard close

匆匆过客 提交于 2019-12-17 17:41:33
问题 I am currently using an ActionBar menu item to display a SearchView in the action bar. When the search menu item is expanded the soft keyboard is displayed which is what I want. Now, when the user presses the back button to close the soft keyboard, I would also like to collapse the SearchView in the action bar. I have tried implementing the following listeners OnKeyListener and OnFocusChangeListener on the MenuItem and the ActionView. I have also tried using OnBackPressed() in the Activity.

Android: how do I get SearchView close button to return the setQueryHint()?

霸气de小男生 提交于 2019-12-17 17:16:09
问题 I have a Search icon in my toolbar that searches a RecyclerView list. Pic 1: When the icon is clicked, the toolbar shows the SearchView's setQueryHint " Search here...". Pic 2: When a character is entered on the SearchView line, in this case the number "4", it is then searched in the RecyclerView list. If the character is not found, a close button "x" appears to the right of the character: Pic 3: My problem is that the default behavior when clicking on the close button "x" is to close the

Hiding of the Toast for long press on actionBar item

空扰寡人 提交于 2019-12-17 16:34:13
问题 Is some possible way how to hide the toast after long-press on the ActionBar item? I didn't setup a title for the item but it is still there - empty toast. <item android:id="@+id/ab_main_menu_dots" android:icon="@drawable/action_icons_dots" android:showAsAction="always"> <menu> <item android:id="@+id/ab_main_menu_my_profile" android:showAsAction="never" android:title="@string/ab_my_profile"> </item> <item android:id="@+id/ab_main_menu_settings" android:showAsAction="never" android:title="