简体   繁体   中英

How to add title to ActionBarSherlock

i can't set title to Action bar sherlock. Here is my code:

public void addNavaigationBar(){

       //Create Action Bar sherlock
ActionBar navigation_bar =  getSupportActionBar();



//Setting standart navigation bar view
navigation_bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);



navigation_bar.setDisplayHomeAsUpEnabled(true);
navigation_bar.setDisplayShowTitleEnabled(true);
navigation_bar.setTitle("Testing");



}

I want to add Testing tile but it don't changes. This should be easy but i can't find it.

Also i am wondering if i could create this navigation bar on top and Tab bar on bottom with Action bar sherlock ?

Thanks.

EDIT: Sorry this is working, it's my other mistake.

Add this into your onCreate

getSupportActionBar().setTitle("<Your Title Here>")

example:

public class MainActivity extends SherlockActivity {
    @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

          //Actionbar Stuff
          getSupportActionBar().setTitle("Hope This Helped!")

    }
//REST OF CLASS HERE
}

First off, I can't find the documentation, but it's not considered best practices to place Android tabs on the bottom - something about that being how it's done on iOS. Theoretically, though, it could be possible with SplitWhenNarrow if you filled the top bar with enough other things - but it would be unreliable, because on a tablet, for example, there might be enough space to load the tabs with everything else on the top bar.

Edit~ Just tested in my code - you can leave out the show title method(true) and still call setTitle on the actionbar, and it sets the title properly.

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