Streetboy
Streetboy

Reputation: 4401

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.

Upvotes: 2

Views: 6185

Answers (2)

LeviRockerSk8er
LeviRockerSk8er

Reputation: 661

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
}

Upvotes: 11

Davek804
Davek804

Reputation: 2804

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.

Upvotes: 3

Related Questions