Fix bug 2835056 - ActionBar doesn't update title properly when set in onCreate
Change-Id: I593315db8df0190c2702a87ebef293e5f798823d
This commit is contained in:
@@ -91,6 +91,7 @@ public class ActionBarView extends ViewGroup {
|
||||
private View mCustomNavView;
|
||||
|
||||
private boolean mShowMenu;
|
||||
private boolean mUserTitle;
|
||||
|
||||
private MenuBuilder mOptionsMenu;
|
||||
private ActionMenuView mMenuView;
|
||||
@@ -212,7 +213,30 @@ public class ActionBarView extends ViewGroup {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the action bar title. This will always replace or override window titles.
|
||||
* @param title Title to set
|
||||
*
|
||||
* @see #setWindowTitle(CharSequence)
|
||||
*/
|
||||
public void setTitle(CharSequence title) {
|
||||
mUserTitle = true;
|
||||
setTitleImpl(title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the window title. A window title will always be replaced or overridden by a user title.
|
||||
* @param title Title to set
|
||||
*
|
||||
* @see #setTitle(CharSequence)
|
||||
*/
|
||||
public void setWindowTitle(CharSequence title) {
|
||||
if (!mUserTitle) {
|
||||
setTitleImpl(title);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTitleImpl(CharSequence title) {
|
||||
mTitle = title;
|
||||
if (mTitleView != null) {
|
||||
mTitleView.setText(title);
|
||||
|
||||
@@ -284,7 +284,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
if (mTitleView != null) {
|
||||
mTitleView.setText(title);
|
||||
} else if (mActionBar != null) {
|
||||
mActionBar.setTitle(title);
|
||||
mActionBar.setWindowTitle(title);
|
||||
}
|
||||
mTitle = title;
|
||||
}
|
||||
@@ -2334,7 +2334,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
} else {
|
||||
mActionBar = (ActionBarView) findViewById(com.android.internal.R.id.action_bar);
|
||||
if (mActionBar != null && mActionBar.getTitle() == null) {
|
||||
mActionBar.setTitle(mTitle);
|
||||
mActionBar.setWindowTitle(mTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user