android-actionbar

Android Actionbar Up button versus system Back button

↘锁芯ラ 提交于 2019-12-17 23:20:42
问题 I'm using the Actionbar and it's "up" button to return from a detail activity to the main activity, which works fine. Similarly, the user can press the system "back" button to return to the main activity. In my main activity, in onCreate() data is downloaded from the internet to display upon app start. I noticed that when I use the Actionbar "up" button to go from detail to main activity, onCreate() is run, re-downloading the data. But onCreate() is not run when I use the system "back" button

Android action bar home button

怎甘沉沦 提交于 2019-12-17 23:04:05
问题 I've set my action bar like so but nothing happens when I click the home up button. The two options below are enabled so shouldn't it go to the home activity automatically? ab.setHomeButtonEnabled(true); ab.setDisplayHomeAsUpEnabled(true); Action Bar @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); final String[] activities; Resources res = getResources(); activities = res.getStringArray(R.array

When and how often is the onPrepareOptionsMenu() method called for ActionBar?

我只是一个虾纸丫 提交于 2019-12-17 22:57:54
问题 It is clear for Activities - the method is being called right before the menu is shown. But what about ActionBar when it is always shown ? How to trigger it to be invoked to dynamically update menuItems ? 回答1: Use invalidateOptionsMenu() to trigger onPrepareOptionMenu() method as suggested by document. On Android 3.0 and higher, you must call invalidateOptionsMenu() when you want to update the menu, because the menu is always open. The system will then call onPrepareOptionsMenu() so you can

Set OnClick Listener on Action Bar Title in Android

帅比萌擦擦* 提交于 2019-12-17 22:46:03
问题 I am working on android application where I am using ActionBar so there one is navigation drawer icon to open it and title of ActionBar in ActionBar . I want to set a click listener on title of ActionBar such that it start a new Activity and set click listener different on navigation drawer icon to open navigation drawer menu. I achieved a click on navigation drawer icon but when I click on title of ActionBar title also then it open the navigation drawer menu. Is there any way to set

ActionBar Up button and Navigation pattern

混江龙づ霸主 提交于 2019-12-17 22:42:24
问题 I want to implement Navigation Pattern in my app with Up button in ActionBar. I have Details Activity, here I can come from home, favorites and search screen. Also I can open this screen from browser(handling specific url). When user press Up button, I use flush() method, to emulate back navigation. But for case, when user come from browser, I want to open home screen instead of previous browser activity. How I can recognize, that previous activity was from another app, and navigate to home

How to recognize whether the Done button is clicked in ActionMode

谁说我不能喝 提交于 2019-12-17 22:26:13
问题 I use ActionMode to select items in a grid. The problem is that I cannot recognize whether exactly the Done button is clicked. The only I can is to know that ActionMode is finished. But pressing Back finishes the ActionMode too. The desired behavior is to accept selection on Done click, and exit ActionMode on Back press. I tried to use ActionMode.setCustomView() but it doesn't affect the Done button. The Activity.onBackPressed() is not called when ActionMode is started. The one solution I've

Action Bar Home Button not functional with nested PreferenceScreen

耗尽温柔 提交于 2019-12-17 22:20:57
问题 I found a workaround to actually enable the ActionBar home button on the nested PreferenceScreen... however it doesn't call OnOptionsItemSelected in my PreferenceActivity. Anyone know a way to actually use the home button on a nested PreferenceScreen? Modification of post 35 here: http://code.google.com/p/android/issues/detail?id=4611 @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { super.onPreferenceTreeClick(preferenceScreen,

Android ActionBar: collapsible SearchView with action button

本秂侑毒 提交于 2019-12-17 22:19:37
问题 How to build ActionBar with collapsible search view with single action item visible, when search view is expanded? To be more descriptive, this is what I need: Note that there are other menu items and android:uiOptions="splitActionBarWhenNarrow" is defined in AndroidManifest.xml . I tried to set up custom search item layout: menu.xml <item android:id="@+id/menu_search" android:actionLayout="@layout/actionbar_search" android:icon="@drawable/action_search" android:showAsAction="always

How to change Toolbar navigation icon and options menu margin

旧城冷巷雨未停 提交于 2019-12-17 21:56:27
问题 Is there any way to change the left margin of the Navigation icon and the right margin of the Action items in Toolbar ? 回答1: I went through the Toolbar source code to find a solution and it turned out to be pretty simple. Toolbar uses two styles to style the toolbar and the navigation icon. Just had to override those styles with my own. <style name="myToolbarNavigationButtonStyle" parent="@style/Widget.AppCompat.Toolbar.Button.Navigation"> <item name="android:minWidth">0dp</item> <item name=

Action items from Viewpager initial fragment not being displayed

左心房为你撑大大i 提交于 2019-12-17 21:48:52
问题 In the application I am developing I am using a ViewPager with fragments and each fragment constructs its own menu independently of all of the other fragments in the ViewPager. The issue is that sometimes the fragments that are initialised by the ViewPager by default (i.e in it's initial state) are not having their items populated into the action items menu. What's worse is that this issue only occurs intermittently. If I swipe through the ViewPager enough so that the fragments are forced to