I followed an online tutorial teaching how to build a custom title bar in android. After you build the layout, here is how to add it onto an activity:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
...
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
And if you add onClickListeners on the buttons which are part of the titlebar, you do this:
Button b1 = (Button) findViewById(R.id.b1);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(MyApp.this, News.class);
startActivity(intent);
}
});
This has to be done everytime you want to add a titlebar to an activity.
Is there a way to create a class for the titlebar and throw all in there so I dont have to repeat myself on each activity?