In my project I'm forced to extend some base activity which in it's turn extend ABS and creates navigation menu.
When my activity called, in onCreate I called
getSupportActionBar().setDisplayHomeAsUpEnabled(true)
but there is no up button appear near the app icon. Instead NavDrawer icon remain there (the three horizontal stripes near the app icon).
How can I change the navdrawer icon to ordinary back button ?
Related
I have an activity A and on that activity, I want to create a new Activity B (or fragment if needs be). On A, I have a hamburger icon and on B, I have left arrow icon. When I created B from A, B is created with left arrow icon but there is no animation. I want to turn hamburger icon to left arrow icon animated as below when creating new activity.
It should work like android gmail application. In Gmail app, when you are in inbox menu, there is a hamburger icon in toolbar and if you click and open one of your mails in inbox list, hamburger icon turns to left arrow animated. When you click to left arrow or back button, the left arrow turns to hamburger icon also animated. Any help?
I can see 2 ways of implementing it. The right way to do this is to use the Toolbar or ActionBar as a shared element between activities and change the state of ActionBarToggle when activity is started and when you return from that activity. But that will not work in pre-lollipop devices. But if you really badly want that to work on older devices, you can start the animation in the Toolbar inside Activity B after the activity B starts, it will not look as smooth as shared element transition, but that is the most straightforward way I see to implement it on older devices.
I use sliding drawer menu in my android project and
I use one drawer menu for all of myActivies
I want in root Activity when click on actionbar`s icon the drawer menu is open!
and in childs Activities when click on actionbar's icon go to parent Activity
like google play or gmail and ...
how I can do this?!
Implement the navigation as usual (with drawertoggle and everything), then call
_toggle.setDrawerIndicatorEnabled(false);
It will hide the drawer icon (the three vertical lines) and display the up caret. The up icon click event will not be handle by the drawer and will finish the activity (if you do so in the OnOptionsItemSelected).
yup, you can use Navigation drawer in the layout and as well as in the java code.
check this url for screenshot
https://developer.android.com/design/media/navigation_drawer_holo_dark_light.png
I have implemented a sliding menu navigation in my app like in this picture.
When the user clicks an item in the sliding menu, a Fragment is created for the corresponding menu entry and it replaces any existing fragment. When the used navigates further away, for example, the top level Fragment is a ThingListFragment for a list of thigs, and he taps one to open a ThingDetailFragment, then I want to replace the sliding menu icon with an icon of a back arrow (so the user must first go back to the top level either by this button or by hardware back button before being able to access the menu).
At this moment I'm setting this manually and it's time consuming and error-prone if I have a lot of fragments like this.
Is there some clever way to achieve this?
Try to make a basic fragment class (for exaple: FragmentBasic) where you register your action bar icons, and then every fragment who needs these icons, extends your FragmentBasic class. after this just implement the extra layout you want
So I'm working on adding ActionBarSherlock and the Navigation Drawer to a project that previously implemented a custom (very poorly written) "action bar". Instead of using fragments and a backstack of activities for navigation, some activities show and hide different layouts. (That is, suppose I am in a list mode and then select a button to go into an edit screen. The app currently hides the list layout and shows another layout.).
So I've added actionbar sherlock and a navigation drawer to all the activities. I want to be able to programmatically switch the navigation icon from the 3 lines to the arrow when certain buttons are pressed.
I can't figure out how to do this though. Any ideas?
Thanks!
The solution to this problem is to use the method:
setDrawerIndicatorEnabled(boolean enable)
inside the ActionBarDrawerToggle class.
After:
drawer.setDrawerListener(toggle);
Use this code:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.select);
It depends how wedded you are to built-in actionbar artifacts. You can always redraw the current actionbar by inflating a layout of your choosing, then calling
getSherlockActivity().getSupportActionBar().setDisplayShowTitleEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowHomeEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowCustomEnabled(true);
// Inflate and do whatever you need to your view...
getSherlockActivity().getSupportActionBar().setCustomView(abView);
getSherlockActivity().getSupportActionBar().show();
When you want to go back to your standard (assuming you're using a DrawerLayout to do your navigation drawer), you can just set make a call to setDisplayShowCustomEnabled(false) (re-enable showHome and showTitle as you please).
As far as I know, customization of the back button can only be done via themes. Besides, swapping the drawer icon for the back icon (within the same Activity) doesn't make sense, since users would still be able to access the navigation drawer by sliding the left most edge to the right. It just wouldn't make sense.
If you absolutely need the back icon, then it would make the most sense to make that screen a new Activity since you would indeed be adding another "level" to the stack, which is what the back icon represents.
As in new action bars, when user clicks on any activity on dashboard, app will take user to new activity, at the same time along with home icon in action bar there would be an arrow showing this activity been started from other activity. How to get this feature with Sherlock android bar?
home icon in action bar there would be an arrow showing this activity been started from other activity
That is not what that arrow means. That arrow means that you are giving the user an option of moving "up" a navigation hierarchy, in addition to the BACK button offering navigation back to the preceding activity. This is described in greater detail in the Android Design documentation.
How to get this feature with Sherlock android bar?
The same way you do with the native action bar: call setDisplayHomeAsUpEnabled(true) on the ActionBar.