我正在开发一个由Fragment
s 组成的应用程序,当我单击按钮时,它应该显示和隐藏。默认情况下,我已将片段设置为可见性消失,即使这对我也不起作用:
FragmentTransaction mFragmentTransaction = getFragmentManager().beginTransaction();
mMenuFragment = new MenuFragment();
mFragmentTransaction.add(R.id.frmMenuBar, mMenuFragment);
mFragmentTransaction.hide(mMenuFragment);
mFragmentTransaction.addToBackStack(null);
mFragmentTransaction.commit();
下面的代码我一直点击按钮。
@Override
protected void onMenuButtonClick(View Button) {
super.onMenuButtonClick(Button);
System.out.println("Botton Clciked");
if (Button.isClickable()) {
FragmentTransaction menuTransaction = getFragmentManager().beginTransaction();
menuTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
menuTransaction.show(mMenuFragment);
menuTransaction.addToBackStack(null);
menuTransaction.commit();
} else {
FragmentTransaction menuShowTransaction = getFragmentManager().beginTransaction();
menuShowTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
menuShowTransaction.hide(mMenuFragment);
menuShowTransaction.addToBackStack(null);
menuShowTransaction.commit();
}
}
请任何人帮助我。