I'm going to kick you into using the% Library of Support Library v4% and Support Library v7%, but I have two suggestions for solving this problem:
Simple mode: restart DrawerLayout
, believing that the ActionBar
you use in Activity
and Strings
will be correct soon after, this can be done as follows:
if (Build.VERSION.SDK_INT < 11) {
Intent intent = activity.getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
activity.finish();
activity.overridePendingTransition(0, 0);
activity.startActivity(intent);
} else {
activity.recreate();
}
This mode is the easiest, but there is a risk of data loss and it has all the overhead of re-creating activity.
The other way, perhaps better depending on the case is to recover Drawer
from ActionBar
and use the ListView
or DrawerLayout
method in notifyDataSetChanged
, forcing the update of the menu items. And with regard to notifyDataSetInvalidated
, just update Adapter
.
The ActionBar can be updated this way:
ActionBar ab = getSupportActionBar();
ab.setTitle(...); // Setar o title novamente, com a lingua correta.
As ActionBar
, you need to either save a reference in your Activity or retrieve it from title
, thus:
// Se ja tiver a referência, não precisa fazer isso..
ListView lv = findViewById(R.id.drawer_list); // resId do ListView
ListAdapter adapter = lv.getAdapter();
adapter.notifyDataSetInvalidate();
// ou dependendo da necessidade
adapter.notifyDataSetChanged();