ActionbarSherlock On navigating to new activity home icon change - android

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.

Related

Why action bar didn't show up after calling the show Unit?

I have 2 formats of action bar, I want to hide home action bar when I am in detail page and want to hide detail action bar when I am in home page. When I start the app, it directs me to home page and it shows me home action bar without showing detail action bar as I expected. I click something on home page that directs me to detail page and when I am on detail page, it also shows detail action bar without showing home action bar as I expected. But trouble comes when I get back to home page again using up button, it doesn't show the home action bar. So the home page doesn't have any action bar displayed. Why using show() doesn't bring back the home action bar?
I would suggest to change from relying on the detail fragment to set the home activity's action bar and instead rely on the home activity to set its own action bar.
For example:
In the onPause() of the home activity, you could add
supportActionBar?.hide().
Then in the onResume() of the home
activity you could add the line supportActionBar?.show().
Try that out and see if that works.

Use jetpack navigation to display back arrrow in the action bar

I have a jetpack navigation graph setup with bottom navigation and an action bar. The bottom navigation has 3 tabs. 1 of these tabs has a detailed fragment that I would like to display the back-arrow on in the action bar.
In MainActivity onCreate(), I've added:
supportActionBar?.setDisplayHomeAsUpEnabled(true)
This displays the back button on every tab & fragment.
How can I prevent display of the back button unless the user is navigated to a non-top level fragment? Is there a method that detects when this particular navigation has occured? If so, I presume I can do something like supportActionBar?.setDisplayHomeAsUpEnabled(false)
Additionally, is there a way I can display a custom back arrow on the child pages? The default arrow does not fit the UI.
Happy to provide more detail if needed.
You could use a combination of setupWithNavController(BottomNavigationView,NavController) and setupActionBarWithNavController(AppCompatActivity,NavController,AppBarConfiguration) from NavigationUI. The first will bind the bottom navigation to the navigation controller, the second will set up the support action bar to regard the navigation.
With the AppBarConfiguration.getTopLevelDestinations() you will be able to configure when to display the back arrow. The default is to only regard the root of the navigation graph as a top level destination, but you can also use another builder to define a set of top level destinations.

Drawer icon requires 2 clicks to open drawer

I have previously used Android Studio's wizard to implement the Master-Detail pattern, and tried to convert the Detail to have a drawer instead of the "up" button.
I went in AndroidManifest.xml and removed the "parent" attribute on the Detail's activity settings, but it still didn't work.
Then I realized that in my Detail Activity's onOptionsItemSelected function, I had forgotten to delete this:
if (id == android.R.id.home) {
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpTo(this, new Intent(this, SongListActivity.class));
return true;
Now it sort-of works, but I have to click the navigation drawer icon 2 times. This is the "navigation drawer icon" I'm referring to:
I noticed that when I click on an item in the Master list, it launches the Detail activity, and it seems to not be in focus. The Navigation bar is not visible at first. This is what I mean by saying "Navigation Bar":
When I click the Navigation Drawer Icon once, the Navigation bar shows up. When I click it again, then the drawer will open.
How do I get it so the new activity is already in focus as soon as it's launched, so I only have to click the Navigation Drawer Icon one time?
Edit: I noticed if I try to click anything in the Action Bar, it takes 2 clicks. I tried several other apps on my Android and they don't have this problem. Usually, they start out with the Navigation Bar already there. Maybe I have some code hiding the Navigation Bar, making the Action Bar not be in focus?
I just looked through my code, and realized that I had forgotten to delete rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); from before. It was in my onCreateView method of my DetailFragment class. I commented it out, and the problem was immediately fixed.

Icon for Up in action bar in Android is an arrow (<-) instead of a arrow head (<)

I have enabled the up button by calling setDisplayHomeAsUpEnabled on getSupportActionBar(). But the icon showing in the action bar is not good compared to the default one.
An arrow icon is appearing as back/up button in the action bar, I was expecting a arrow head only for button default. All the examples in web are showing array head for back /up button.
How to make the icon just arrow head ?
You can change the action bar navigation icon by the below method
actionBar.setHomeAsUpIndicator(R.drawable.your_icon);

Non-standard back button in Action Bar Android

I've seen in several apps a non-standard back button (image #2) in the action bar,
Normally when I config a navigation drawer or the setDisplayHomeAsUpEnabled it just looks like image #1
How can i accomplish the non-standard style?
That is not a back button. It is sometimes called a "hamburger icon", and it is specifically used for indicating the presence of DrawerLayout navigation. You can find more information in the Android documentation. You can see more about the icon's functionality here.

Categories

Resources