i changed the logo to an action icon and i want to perform an action when the logo is clicked.
How can i customize the action when the home logo in action bar is clicked?
thank you
In onOptionsItemSelected() of your activity, watch for an ID of android.R.id.home -- that will be when the home icon/logo is pressed. You can then perform whatever action makes sense (e.g., move to your app's main screen).
Related
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.
I have default action bar with home buttom, logo/icon, title
I need make logo/icon (not home buttom) or title clickable (clickListener)
How to make it in default action bar?
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);
I'm having action bar which display application Name, search and more action menu item, though i'm using sherlock library for that. I want to disable the toast of search and more item when i performing long press event in the action bar. Did anyone knows how to disable / redefine long press event.
This is a feature of the native action bar. It cannot be removed.
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.