hakki
hakki

Reputation: 6521

ActionBar setTitle() with sdk version 8 on Android

Hi this is short question but very important for me.

I defined an ActionBar object. Then I set title to action bar with my specific String like below. But the problem is about minimum SDK version.

I want to use minimum sdk version 8 but ActionBar enforces me to sdk version 11. Is there way to solve this problem?

ActionBar actionBar = getActionBar();
actionBar.setTitle(country_name);

Upvotes: 0

Views: 375

Answers (2)

BNut
BNut

Reputation: 41

You can accomplish that by

ActionBar actionbar = getSupportActionBar();
actionbar.setTitle("some title");

As describe here on Android developer site.

getSupportActionBar() // is the Support library version of getActionBar()

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1006819

android.app.ActionBar itself is only available on API Level 11+. If you want to use an action bar on earlier versions of Android, you will need some form of backport, such as ActionBarSherlock.

Upvotes: 2

Related Questions