- я использую actionsherlockbar Library + JfenisteinSlidingMenu
вопрос: как добавить динамически optionmenu находится в ActionBar в каждом фрагментекак добавить параметрMenu в каждый фрагмент. (Android + actionsherlock + jfensteinSlidingMenu
я попытался ниже, но optionmenu такое же? на каждой странице .. как я могу это сделать?
public class FragmentChangeActivity extends BaseActivity {
private Fragment mContent;
private String json = null;
public FragmentChangeActivity() {
super(R.string.changing_fragments);
}
@SuppressWarnings("unused")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// set the Above View
if (savedInstanceState != null)
mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent");
if (mContent == null)
mContent = new ColorFragment(android.R.color.white);
// set the Above View
setContentView(R.layout.content_frame);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.content_frame, mContent)
.commit();
// set the Behind View
ColorMenuFragment colorMenuFragment = new ColorMenuFragment();
LeftMenuFragment leftMenu = new LeftMenuFragment();
setBehindContentView(R.layout.menu_frame);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.menu_frame, colorMenuFragment)
.commit();
// customize the SlidingMenu
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
getSupportFragmentManager().putFragment(outState, "mContent", mContent);
}
public void switchContent(Fragment fragment) {
mContent = fragment;
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.content_frame, fragment)
.commit();
getSlidingMenu().showAbove();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
toggle();
return true;
case R.id.github:
Utils.goToGitHub(this);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.main, menu);
return true;
}
}