It seems like the best way to handle this is to have a condition you check when the drawer closes.
Here's a short example:
private boolean mNoTitleChange;
private int mPosition = -1;
@Override
public void onDrawerClosed(View view) {
if (mNoTitleChange) {
startActivity(new Intent(CurrentActivity.this, NewActivity.class));
mNoTitleChange = false;
return;
}
getActionBar().setTitle(mTitle);
invalidateOptionsMenu();
}
@Override
protected void onResume() {
super.onResume();
if (mPosition != -1) {
setTitle(mYourTitles[mPosition]);
mPosition = -1;
}
}
Whenever you select an item in your DrawerLayout
, adjust the boolean
as needed.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mNoTitleChange = true;
mPosition = position;
mDrawerLayout.closeDrawer(mDrawerList);
}