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

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

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

Fragment.getChildFragmentManager介绍

暂无

代码示例

代码示例来源:origin: googlesamples/easypermissions

@Override
public FragmentManager getSupportFragmentManager() {
  return getHost().getChildFragmentManager();
}

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

public ImagePagerAdapter(Fragment fragment) {
 // Note: Initialize with the child fragment manager.
 super(fragment.getChildFragmentManager());
}

代码示例来源:origin: VictorAlbertos/RxActivityResult

@Nullable
  Fragment getTargetFragment(List<Fragment> fragments) {
    if (fragments == null) return null;
    for (Fragment fragment : fragments) {
      if (fragment != null && fragment.isVisible() && fragment.getClass() == clazz) {
        return fragment;
      } else if (fragment != null && fragment.isAdded() && fragment.getChildFragmentManager() != null) {
        List<Fragment> childFragments = fragment.getChildFragmentManager().getFragments();
        Fragment candidate = getTargetFragment(childFragments);
        if (candidate != null) return candidate;
      }
    }
    return null;
  }
}

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

@Override
public void onBackPressed() {
  if (DEBUG) Log.v(TAG, "onBackPressed:");
  // Fragment内の子Fragmentを切り替えた時にbackキーを押すと
  // Fragment自体がpopBackされてしまうのに対するworkaround
  final FragmentManager fm = getSupportFragmentManager();
  final Fragment fragment = fm.findFragmentById(R.id.container);
  if (fragment instanceof BaseFragment) {
    final FragmentManager child_fm = fragment.getChildFragmentManager();
    if (child_fm.getBackStackEntryCount() > 0) {
      // HomeFragmentの子Fragmentがバックスタックに有る時はそれをpopBackする
      child_fm.popBackStack();
      return;
    }
    if (((BaseFragment) fragment).onBackPressed()) {
      return;
    }
  }
  super.onBackPressed();
}

代码示例来源:origin: jruesga/rview

private void performShowDraftMessageDialog(View v, Integer line, boolean isLeftSide,
    String comment, int requestCode, Bundle requestData) {
  final String side = isLeftSide
      ? getString(R.string.options_base_left)
      : getString(R.string.options_base_right);
  final String subtitle;
  if (line == null) {
    // File comment
    subtitle = getString(R.string.draft_file_comment, side);
  } else {
    // Line comment
    subtitle = getString(R.string.draft_line_comment, line, side);
  }
  EditDialogFragment fragment = EditDialogFragment.newInstance(
      getString(R.string.draft_title), subtitle, comment, getString(R.string.action_save),
      getString(R.string.draft_hint), false, true, true, null, v, requestCode, requestData);
  if (getParentFragment() != null) {
    fragment.show(getParentFragment().getChildFragmentManager(), EditDialogFragment.TAG);
  } else {
    Log.w(TAG, "Unsupported operation: getParentFragment() returns null");
  }
}

相关文章