简体   繁体   中英

change ActionBar layout when click on button

I want to change my actionbar for an actionbar with custom layout when i click on a button.

I don't have found solution.

I tried

getActionBar().setCustomView(R.layout.actionbar_layout); 

but it does not work.

Thx for your help !

Try this code:

getActionBar().setDisplayShowCustomEnabled(true);
LayoutInflater inflater = 
              (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.actionbar_layout, null);
getActionBar().setCustomView(view);

I hope it helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM