androidx.fragment.app.Fragment.getFragmentManager()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中androidx.fragment.app.Fragment.getFragmentManager()方法的一些代码示例,展示了Fragment.getFragmentManager()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fragment.getFragmentManager()方法的具体详情如下:
包路径:androidx.fragment.app.Fragment
类名称:Fragment
方法名:getFragmentManager

Fragment.getFragmentManager介绍

暂无

代码示例

代码示例来源:origin: saki4510t/libcommon

/**
 * ダイアログ表示のためのヘルパーメソッド
 * @param parent
 * @param titleResId
 * @param initialColor
 * @return
 */
public static ColorPickerDialogV4 show(
  @NonNull final Fragment parent,
  @StringRes final int titleResId, final int initialColor) {

  final ColorPickerDialogV4 dialog = newInstance(titleResId, initialColor);
  dialog.setTargetFragment(parent, 0);
  dialog.show(parent.getFragmentManager(), TAG);
  return dialog;
}

代码示例来源:origin: andstatus/andstatus

public static void showYesCancelDialog(Fragment fragment, int titleId, int messageId, final ActivityRequestCode requestCode) {
  DialogFragment dialog = new YesCancelDialog();
  Bundle args = new Bundle();
  args.putCharSequence(DIALOG_TITLE_KEY,
      fragment.getText(titleId));
  args.putCharSequence(
      DIALOG_MESSAGE_KEY,
      fragment.getText(messageId));
  dialog.setArguments(args);
  dialog.setTargetFragment(fragment, requestCode.id);
  dialog.show(fragment.getFragmentManager(), YES_CANCEL_DIALOG_TAG);
}

代码示例来源:origin: andstatus/andstatus

/** See http://stackoverflow.com/questions/10285047/showdialog-deprecated-whats-the-alternative */
public static void showOkDialog(Fragment fragment, int titleId, int messageId, final int requestCode) {
  DialogFragment dialog = new OkDialogFragment();
  Bundle args = new Bundle();
  args.putCharSequence(DIALOG_TITLE_KEY, fragment.getText(titleId));
  args.putCharSequence(DIALOG_MESSAGE_KEY, fragment.getText(messageId));
  dialog.setArguments(args);
  dialog.setTargetFragment(fragment, requestCode);
  dialog.show(fragment.getFragmentManager(), OK_DIALOG_TAG);
}

代码示例来源:origin: andstatus/andstatus

/** See http://stackoverflow.com/questions/10285047/showdialog-deprecated-whats-the-alternative */
public static void showOkDialog(Fragment fragment, int titleId, int messageId, final int requestCode) {
  DialogFragment dialog = new OkDialogFragment();
  Bundle args = new Bundle();
  args.putCharSequence(DIALOG_TITLE_KEY, fragment.getText(titleId));
  args.putCharSequence(DIALOG_MESSAGE_KEY, fragment.getText(messageId));
  dialog.setArguments(args);
  dialog.setTargetFragment(fragment, requestCode);
  dialog.show(fragment.getFragmentManager(), OK_DIALOG_TAG);
}

代码示例来源:origin: andstatus/andstatus

public static void showYesCancelDialog(Fragment fragment, int titleId, int messageId, final ActivityRequestCode requestCode) {
  DialogFragment dialog = new YesCancelDialog();
  Bundle args = new Bundle();
  args.putCharSequence(DIALOG_TITLE_KEY,
      fragment.getText(titleId));
  args.putCharSequence(
      DIALOG_MESSAGE_KEY,
      fragment.getText(messageId));
  dialog.setArguments(args);
  dialog.setTargetFragment(fragment, requestCode.id);
  dialog.show(fragment.getFragmentManager(), YES_CANCEL_DIALOG_TAG);
}

代码示例来源:origin: google/android-transition-examples

/**
  * Handles a view click by setting the current position to the given {@code position} and
  * starting a {@link  ImagePagerFragment} which displays the image at the position.
  *
  * @param view the clicked {@link ImageView} (the shared element view will be re-mapped at the
  * GridFragment's SharedElementCallback)
  * @param position the selected view position
  */
 @Override
 public void onItemClicked(View view, int position) {
  // Update the position.
  MainActivity.currentPosition = position;
  // Exclude the clicked card from the exit transition (e.g. the card will disappear immediately
  // instead of fading out with the rest to prevent an overlapping animation of fade and move).
  ((TransitionSet) fragment.getExitTransition()).excludeTarget(view, true);
  ImageView transitioningView = view.findViewById(R.id.card_image);
  fragment.getFragmentManager()
    .beginTransaction()
    .setReorderingAllowed(true) // Optimize for shared element transition
    .addSharedElement(transitioningView, transitioningView.getTransitionName())
    .replace(R.id.fragment_container, new ImagePagerFragment(), ImagePagerFragment.class
      .getSimpleName())
    .addToBackStack(null)
    .commit();
 }
}

相关文章