X

ActionBar

ActionBar:
ActionBar is an Android component, which is in the top of Activity with some properties. The properties are title, icon, background color, menus

To work with ActionBar, we have following set of steps.

1) Get the object of ActionBar using getSupportActionBar() as mentioned below
ActionBar actionBar = getSupportActionBar();
2) To change title, we use setTitle(title) method
actionBar.setTitle(“This is Android class”);
3) To make logo visible, we have following method
actionBar.setDisplayShowHomeEnabled(true);
4) To change logo, we can use either of the 2 methods
actionBar.setIcon(R.drawable.my_icon);
(or)
actionBar.setLogo(R.drawable.my_icon);
5) To change background color, we will use the following method
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(“#ff0000”)));
6) To enable back button, we use following method
actionBar.setDisplayShowHomeAsUpEnabled(true);

 

Create an Android Application to work with ActionBar
Refer source on

 

 

 

 

 

 

Comments are closed.