package com.hfad.workout; import android.app.FragmentTransaction; import android.app.Activity; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends Activity implements WorkoutListListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public void itemClicked(long id) { // Create a new WorkoutDetailFragment to replace the previous one. WorkoutDetailFragment details = new WorkoutDetailFragment(); // Set the new fragment's properties. details.setWorkoutId(id); // Call up the fragment manager to start a new transaction. FragmentTransaction ft = getFragmentManager().beginTransaction(); // Specify the transactions you want to perform: // replace whatever is in the fragment container with the new fragment ft.replace(R.id.fragment_container, details); // Add this transaction to the back stack so that user can navigate with back button // (null means no label assigned to this transaction -- 99% of the time you won't need // a label) ft.addToBackStack(null); // Specify a visual transition style to use between old and new fragments ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); // Do it! ft.commit(); } }