예제 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    playground = (PlaygroundFragment) getFragmentManager().findFragmentByTag(TAG_PLAYGROUND);
    result = (ResultFragment) getFragmentManager().findFragmentByTag(TAG_RESULT);

    if (playground == null) {
      playground = new PlaygroundFragment();
      getFragmentManager()
          .beginTransaction()
          .add(android.R.id.content, playground, TAG_PLAYGROUND)
          .commit();
    }

    if (result == null) {
      result = ResultFragment.newInstance();
      getFragmentManager()
          .beginTransaction()
          .add(android.R.id.content, result, TAG_RESULT)
          .hide(result)
          .commit();
    }

    if (!playground.isVisible() && !result.isVisible()) {
      getFragmentManager().beginTransaction().hide(result).show(playground).commit();
    }
  }