Change custom actionbar title
android, android-actionbar, title
Solution
Modify the setActionbarTitle() as below
private void setActiobarTitle(String title)
{
View v = getActionbar().getCustomView();
TextView titleTxtView = (TextView) v.findViewById(R.id.actionbarTitle);
titleTxtView.setText(title);
}
Problem
I'm using a custom layout to center the title of the actiobar. ``` ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(R.layout.action_bar); ``` where action_bar is a simple linear layout with a textview My problem is that I need every activity to have different names - and I need to change theme programmatically. So I'm trying something like this: ``` private void setActiobarTitle(String title) { LayoutInflater inflator = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(R.layout.action_bar, null); TextView titleTxtView = (TextView) v.findViewById(R.id.actionbarTitle); titleTxtView.setText(title); } ``` When debuging the textview is found and initialized and everything seems to be okay - but the title doesn't change. Can anyone please tell me what seems to be the problem?