コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_movie_detail);

    if (savedInstanceState == null) {
      Bundle arguments = new Bundle();
      arguments.putInt(
          MovieDetailActivityFragment.MOVIE_DETAIL_ID,
          getIntent().getIntExtra(MovieDetailActivityFragment.MOVIE_DETAIL_ID, 1));

      MovieDetailActivityFragment fragment = new MovieDetailActivityFragment();
      fragment.setArguments(arguments);

      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.fragment_movie_detail_container, fragment)
          .commit();
    }
  }
コード例 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_movie_detail);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_detail);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String InstanceTagLocal = PopMoviesConstants.DETAIL_ACTIVITY_INSTANCE_TAG;
    if (savedInstanceState == null) {
      if (PopMoviesConstants.DEBUG)
        Log.d("PopMovies1", LOG_TAG + ":" + " OnCreate : attaching fragment");
      Bundle arguments = new Bundle();
      long id = getIntent().getLongExtra(InstanceTagLocal, -1);
      arguments.putLong(InstanceTagLocal, id);
      MovieDetailActivityFragment movieDetailFragment = new MovieDetailActivityFragment();
      movieDetailFragment.setArguments(arguments);
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.movie_detail_container, movieDetailFragment)
          .commit();
    }
  }