Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Toast.makeText(this, "DetailsActivity", Toast.LENGTH_SHORT).show();

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      // If the screen is now in landscape mode, we can show the
      // dialog in-line with the list so we don't need this activity.
      finish();
      return;
    }

    if (savedInstanceState == null) {
      // During initial setup, plug in the details fragment.

      // create fragment
      DetailsFragment details = new DetailsFragment();

      // get and set the position input by user (i.e., "index")
      // which is the construction arguments for this fragment
      details.setArguments(getIntent().getExtras());

      //
      getFragmentManager().beginTransaction().add(android.R.id.content, details).commit();
    }
  }
Пример #2
0
  public static DetailsFragment newInstance(int index) {
    DetailsFragment f = new DetailsFragment();

    // Supply index input as an argument.
    Bundle args = new Bundle();
    args.putInt("index", index);
    f.setArguments(args);

    return f;
  }