In action bar, there is an icon called "up affordance" showed below (the left-most one):
In my Activity onCreate()
method, I have set the following things:
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
My Question is:
how can I implement an onClickListener
on this "up affordance" icon, so that when user click on it, the application will be navigated to the upper level hierarchy ?
how can I have only the left arrow without the android default icon of "up affordance" part on action bar?
For implementing an onClickListener, instead just catch it in onOptionsItemSelected:
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case android.R.id.home:
// Do what you want here
return true;
default:
return super.onOptionsItemSelected(item);
}
}
For question two, this page states:
Using a logo instead of icon
By default, the system uses your application icon in the action bar, as specified by the android:icon attribute in the or element. However, if you also specify the android:logo attribute, then the action bar uses the logo image instead of the icon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With