SlidingMenu
SlidingMenu copied to clipboard
update SlidingMenu Mode from another Fragment
Hi,
I have a SettingFragment
that contains options to change app language, for example when I change language to french I must set the menu to the LEFT ;setMode(SlidingMenu.LEFT)
, and when I change it to arabic I must set the languague to the RIGHT setMode(SlidingMenu.RIGHT)
.
To achieve taht I use the observer pattern as following :
MainActivity extends FragmentActivity {
....
@Override
public void propertyChange(PropertyChangeEvent event) {
final String mLanguge = (String) event.getNewValue();
Log.v("Langue",mLanguge );
MainMenuActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
if(mLanguge .equals(getResources().getString(R.string.params_arabe_key_pref)))
menu.setMode(SlidingMenu.RIGHT);
else
menu.setMode(SlidingMenu.LEFT);
// refresh the SlidingMenu
menu.invalidate();
}
});
}
(Note this methode is declared inside the MainActivity
and it's called when the user change the app language)