Home » Android » ActionBar Compat ActionBarActivity setTitle does not work in Android 2.X

ActionBar Compat ActionBarActivity setTitle does not work in Android 2.X

Posted by: admin May 14, 2020 Leave a comment

Questions:

My question is same as this issue.

I’ve setup the Android Support Library by following this instruction. (I’m using Support Library, revision 19.0.1)

In this issue, the google’s staff said “this is fixed in the Support Library v19”. However, it does not work in my device(Gingerbread).

I’ve tried to find solution, but I couldn’t find that. Any ideas?

How to&Answers:

Step 1: Import appcompat from your adt-bundle folder to your eclipse .

Link:

adt-bundle-windows-x86-20130917\adt-bundle-windows-x86-20130917\sdk\extras\android\support\v7\appcompat

Step 2: Make it a Library.

-Right Click on android-support-v7-appcompat.

-click on properties.

-click on Android(below resource).

-Mark it as “isLibrary”.

Step 3: Use it in your project.

-Right Click on your Project.

-click on properties.

-click on Android(below resource).

-click on “Add”.

-click on android-support-v7-appcompat to make it your Library for your project.

Step 4: call Action Bar in you Activity.

ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);

Step 5: Make an styles.Xml file in “Values” folder if do not exist and add under mention code.

<resources>

<style name="ProgressBarStyle" parent="@android:style/Widget.ProgressBar.Horizontal"/>

</resources>

Step 6: Update your manifest File, add it under “application”.

android:theme=”@style/Theme.Base.AppCompat.Light.DarkActionBar”

ALL THE BEST, revert back if you face any problem.

Answer:

Use getSupportActionBar().setTitle().