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

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

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

Fragment.setArguments介绍

暂无

代码示例

代码示例来源:origin: ankidroid/Anki-Android

args = new Bundle();
  args.putInt(ARG_SECTION_NUMBER, sectionNumber);
  fragment.setArguments(args);
  return (ChartFragment) fragment;
case TODAYS_STATS_TAB_POSITION:
  args = new Bundle();
  args.putInt(ARG_SECTION_NUMBER, sectionNumber);
  fragment.setArguments(args);
  return (OverviewStatisticsFragment) fragment;
default:

代码示例来源:origin: westnordost/StreetComplete

@Override protected void onPostCreate(@Nullable Bundle savedInstanceState)
{
  super.onPostCreate(savedInstanceState);
  if(savedInstanceState == null)
  {
    String fragmentClass = getIntent().getStringExtra(EXTRA_FRAGMENT_CLASS);
    if (fragmentClass != null)
    {
      try
      {
        Class c = Class.forName(fragmentClass);
        Fragment f = (Fragment) c.newInstance();
        f.setArguments(getIntent().getExtras());
        setCurrentFragment(f, false);
      } catch (Exception e)
      {
        throw new RuntimeException(e);
      }
    }
  }
}

代码示例来源:origin: andriydruk/BonjourBrowser

protected static Fragment fillArguments(Fragment fragment, String domain, String regType) {
  Bundle bundle = new Bundle();
  bundle.putString(KEY_DOMAIN, domain);
  bundle.putString(KEY_REG_TYPE, regType);
  fragment.setArguments(bundle);
  return fragment;
}

代码示例来源:origin: smarek/Simple-Dilbert

@Override
public Fragment getItem(int position) {
  Fragment f = new DilbertFragment();
  Bundle bundle = new Bundle();
  bundle.putString(DilbertFragment.ARGUMENT_DATE, favorites.get(position)
      .getDate().toString(DilbertPreferences.DATE_FORMATTER));
  f.setArguments(bundle);
  return f;
}

代码示例来源:origin: smarek/Simple-Dilbert

@Override
public Fragment getItem(int position) {
  Fragment f = new DilbertFragment();
  Bundle bundle = new Bundle();
  bundle.putString(
      DilbertFragment.ARGUMENT_DATE,
      getDateForPosition(position).toString(
          DilbertPreferences.DATE_FORMATTER));
  f.setArguments(bundle);
  return f;
}

代码示例来源:origin: 8enet/AppOpsX

@Override
@NonNull
public Fragment getItem(int position) {
 Fragment fragment = mFragments.get(position);
 if (fragment == null) {
  switch (position) {
   case 0:
    fragment = new ExportFragment();
    fragment.setArguments(new Bundle(getIntent().getExtras()));
    break;
   case 1:
    fragment = new ImportFragment();
    break;
  }
  if (fragment != null) {
   mFragments.put(position, fragment);
  }
 }
 return fragment;
}

代码示例来源:origin: TUM-Dev/Campus-Android

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  //Enable the direct access of a specific sub section, e.g.: cards
  Intent intent = getIntent();
  Bundle args = new Bundle();
  if (intent != null && intent.getExtras() != null) {
    args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, intent.getExtras()
                                      .getString(Const.PREFERENCE_SCREEN));
  }
  if (savedInstanceState == null) {
    // Create the fragment only when the activity is created for the first time. ie. not after orientation changes
    Fragment fragment = getSupportFragmentManager().findFragmentByTag(SettingsFragment.FRAGMENT_TAG);
    if (fragment == null) {
      fragment = new SettingsFragment();
    }
    fragment.setArguments(args);
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.settings_frame, fragment, SettingsFragment.FRAGMENT_TAG);
    ft.commit();
  }
}

相关文章