enable and disable logo in hamburger menu android - android

Actual scenario.
I have an drawer menu with some menu options. Each menu click replace the fragment of the activity in which i want to show the logo with hamburger menu in home page fragment only and in rest of other pages i want hide it.
i tried like below
((AppCompatActivity) getActivity()).getSupportActionBar().setLogo(null);
to in rest of the fragments onResume() method
But in result menu logo gone when it call setLogo(null); but it was not come to previous state on home page even after setting setLogo(R.drawable.logo)
Advance thanks for helping..

To disable just call:
yourDrawerToggle.setDrawerIndicatorEnabled(false);

Related

how to make back option in toolbar/ActionBar when I move from one fragment to other

I am facing the problem in android regarding with Fragments.
See I am using Navigation drawer activity. Inside that home fragment is placed. After pressing a button in home fragment, it will move to second fragment. So my problem is how to navigate back icon option in tool bar, so that I can move back to home fragment from second fragment with the help of tool bar, like flipkart app.
In flipkart app, inside navigation drawer fragment, if we select an item it moved to that fragment. Then it creates back option in tool bar to navigate back to the main fragment.
please anyone help
Use
getActionBar().setDisplayHomeAsUpEnabled(true);
or (if you use appcompat ActionBar)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Use this
((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
or(if your activity is AppCompat then )
((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

Use drawer indicator as back button

I'm using MaterialDrawer library to implement a basic material drawer in my app.
I wasted more than two days trying to figure out how to transform the menu toggle button (burger) to a back button, like Gmail app when you open an email.
In Gmail app when you open an email the menu icon is animated into a back arrow but the menu drawer remains still available.
I've tried to use ValueAnimator to animate the icon as explained here.
I've setted an onAnimationEnd listener to replace the menu icon with a working back button:
result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
After doing that the menu drawer slide position get unlinked from the menu drawer icon animation, and when i try to restore the menu drawer button and animate it backwards it gets stuck:
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);
Actually a similar question has been already asked, and has been marked has duplicated when it is not: Navigation Drawer with Burger to back arrow animation on Lollipop

Use navigation drawer menu in child Activity

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

Setting Navigation Icon on Android ActionBar

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.

back press to switch from action bar navigation mode tabs to standard

I have a list fragment, which contains a list of items. When I tap on some of the items, the navigation mode changes from NAVIGATION_MODE_STANDARD to NAVIGATION_MODE_TABS and two tabs will appear. I want the navigation mode to change back to standard (with both tabs removed) when I press on back button. However, I cannot find to place to put addToBackStack() and thus unable to implement this navigation. Could someone give me some suggestions?
Many thanks in advance

Categories

Resources