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.
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
.)