use of android.app.FragmentTransaction in project superCleanMaster by joyoyao.
the class DialogUtil method showAlertDialog.
/**
* 描述:对话框dialog (图标,标题,View内容).
* @param icon
* @param title 对话框标题内容
* @param view 对话框提示内容
*/
public static AlertDialogFragment showAlertDialog(int icon, String title, View view) {
FragmentActivity activity = (FragmentActivity) view.getContext();
AlertDialogFragment newFragment = AlertDialogFragment.newInstance(icon, title, null, view, null);
FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
// 指定一个系统转场动画
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
newFragment.show(ft, mDialogTag);
return newFragment;
}
use of android.app.FragmentTransaction in project superCleanMaster by joyoyao.
the class DialogUtil method showAlertDialog.
/**
* 描述:对话框dialog (图标,标题,String内容).
* @param context
* @param icon
* @param title 对话框标题内容
*
*/
public static AlertDialogFragment showAlertDialog(Context context, int icon, String title, String message) {
FragmentActivity activity = (FragmentActivity) context;
AlertDialogFragment newFragment = AlertDialogFragment.newInstance(icon, title, message, null, null);
FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
// 指定一个系统转场动画
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
newFragment.show(ft, mDialogTag);
return newFragment;
}
use of android.app.FragmentTransaction in project superCleanMaster by joyoyao.
the class DialogUtil method removeDialog.
/**
* 描述:移除Fragment.
*
* @param context
* the context
*/
public static void removeDialog(Context context) {
try {
FragmentActivity activity = (FragmentActivity) context;
FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
// 指定一个系统转场动画
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
ft.commit();
} catch (Exception e) {
// 可能有Activity已经被销毁的异常
e.printStackTrace();
}
}
use of android.app.FragmentTransaction in project XobotOS by xamarin.
the class PreferenceActivity method startPreferencePanel.
/**
* Start a new fragment containing a preference panel. If the prefences
* are being displayed in multi-pane mode, the given fragment class will
* be instantiated and placed in the appropriate pane. If running in
* single-pane mode, a new activity will be launched in which to show the
* fragment.
*
* @param fragmentClass Full name of the class implementing the fragment.
* @param args Any desired arguments to supply to the fragment.
* @param titleRes Optional resource identifier of the title of this
* fragment.
* @param titleText Optional text of the title of this fragment.
* @param resultTo Optional fragment that result data should be sent to.
* If non-null, resultTo.onActivityResult() will be called when this
* preference panel is done. The launched panel must use
* {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
* @param resultRequestCode If resultTo is non-null, this is the caller's
* request code to be received with the resut.
*/
public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) {
if (mSinglePane) {
startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0);
} else {
Fragment f = Fragment.instantiate(this, fragmentClass, args);
if (resultTo != null) {
f.setTargetFragment(resultTo, resultRequestCode);
}
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(com.android.internal.R.id.prefs, f);
if (titleRes != 0) {
transaction.setBreadCrumbTitle(titleRes);
} else if (titleText != null) {
transaction.setBreadCrumbTitle(titleText);
}
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.addToBackStack(BACK_STACK_PREFS);
transaction.commitAllowingStateLoss();
}
}
use of android.app.FragmentTransaction in project XobotOS by xamarin.
the class PreferenceActivity method startPreferenceFragment.
/**
* Start a new fragment.
*
* @param fragment The fragment to start
* @param push If true, the current fragment will be pushed onto the back stack. If false,
* the current fragment will be replaced.
*/
public void startPreferenceFragment(Fragment fragment, boolean push) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(com.android.internal.R.id.prefs, fragment);
if (push) {
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.addToBackStack(BACK_STACK_PREFS);
} else {
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
}
transaction.commitAllowingStateLoss();
}
Aggregations