I need to develop an app where it is possible to change the action bar title style dynamically.
In tried to achieve this by accessing the action bar title in the following way:
(TextView) findViewById(
Resources.getSystem().getIdentifier(
"action_bar_title",
"id",
"android"
)
);
I then edit the style just like normal TextView.
This seems to work fine before the mobile phone changes orientation.
After the orientation changed however, I can still get the TextView ( i.e. not return null ) by the above code but changes to the textview are no longer reflected.
Might anybody know why?
==============================================================
Thanks for your quick reply, the code i used to modify the TextView :
@Override
public void onConfigurationChanged( Configuration newConfig )
{
super.onConfigurationChanged( newConfig );
int titleId = Resources.getSystem().getIdentifier( "action_bar_title", "id", "android" );
TextView title = (TextView) activity.findViewById( titleId );
title.setTextColor( Color.parseColor("#ff0000") );
title.setBackgroundColor( Color.parseColor("#00ff00") );
title.setText( ""+ new Random().nextInt(9999) );
}
After the orientation changed, method onConfigurationChanged is being triggered. However, the action bar title TextView are no longer reflected.
I can also use titleView.getText().toString() to get the correct text i assigned earlier.
However, the action bar title has no any visible changes. What i feel is the TextView i extracted is not the Action Bar title.