除了“fragmentManager”无法解决之外,其他一切都很好,我在这里做错了什么?本教程跳过了本节的某些部分...
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_activity_frame);
FragmentManager frgman = getSupportFragmentManager();
FragmentTransaction frgtrans = frgman.beginTransaction();
Fragment frag = new Side_Fragment();
frgtrans.replace(R.id.frag_frame, frag, "SIDE");
frgtrans.commit();
}
public void swapFrag(View v) {
FragmentManager fragmentManger = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment current = fragmentManager.findFragmentByTag("SIDE");
if(!current.isVisible())
{
fragmentTransaction.replace(R.id.frag_frame, picture, "PIC");
}
else
{
fragmentTransaction.replace(R.id.frag_frame, side, "SIDE");
}
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();