Chen Jay
Chen Jay

Reputation: 35

Android shared title bar with functionality

I have a custom title bar cross all of activities. The problem is that I need to write this code

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.vitamin_chart);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);

on all of activities.

Is there a way to write the setting of title bar and functionality in one place?

Thanks.

Upvotes: 0

Views: 55

Answers (2)

NIPHIN
NIPHIN

Reputation: 1081

If you are using ActionBarActivity the use this getActionBar().setTitle("your_custom_title_here")

Upvotes: 0

Code-Apprentice
Code-Apprentice

Reputation: 83527

You could make an abstract class TitleBarActivity with this code and then extend TitleBarActivity from all of your other activities. (Be sure that TitleBarActivity extends Activity.)

Upvotes: 2

Related Questions