private static SampleDescriptionDialogFragment newInstance(int titleResId, int descriptionResId) { SampleDescriptionDialogFragment dialogFragment = new SampleDescriptionDialogFragment(); Bundle args = new Bundle(); args.putInt(BUNDLE_TITLE_RES_ID, titleResId); args.putInt(BUNDLE_DESCRIPTION_RES_ID, descriptionResId); dialogFragment.setArguments(args); return dialogFragment; }
public static void show(FragmentActivity activity, int titleResId, int descriptionResId) { FragmentManager fragmentManager = activity.getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Fragment prev = fragmentManager.findFragmentByTag(FRAGMENT_TAG); if (prev != null) { fragmentTransaction.remove(prev); } fragmentTransaction.addToBackStack(null); SampleDescriptionDialogFragment.newInstance(titleResId, descriptionResId) .show(fragmentManager, FRAGMENT_TAG); }