protected static Fragment newInstance(Fragment fragment, Configuration configuration) { Bundle args = new Bundle(); args.putSerializable(ARG_CONFIGURATION, configuration); fragment.setArguments(args); return fragment; }
@Override public Fragment getItem(int position) { Fragment fragment = new GistFragment(); Bundle args = new Bundle(); args.putString(EXTRA_GIST_ID, ids[position]); fragment.setArguments(args); return fragment; }
@Override public Fragment getItem(final int position) { GistFile file = files[position]; Fragment fragment = new GistFileFragment(); Bundle args = new Bundle(); args.putParcelable(EXTRA_GIST_FILE, file); fragment.setArguments(args); return fragment; }
private void switchFragment(Fragment fragment, User organization) { if (organization != null) { Bundle args = new Bundle(); args.putParcelable("org", organization); fragment.setArguments(args); } FragmentManager manager = getSupportFragmentManager(); manager.beginTransaction().replace(R.id.container, fragment).commit(); drawerLayout.closeDrawer(GravityCompat.START); currentFragment = fragment; }
/** * Set the argument of Fragment. * * @param fragment a fragment * @return a fragment */ public <T extends Fragment> T into(T fragment) { fragment.setArguments(get()); return fragment; }
@Override public Fragment getItem(int position) { try { Class<?> clazz = tabInfos.get(position).fragmentClass; Fragment fragment = (Fragment) clazz.newInstance(); if (tabInfos.get(position).arguments != null) { fragment.setArguments(tabInfos.get(position).arguments); } return fragment; } catch (Exception e) { throw new RuntimeException("Cannot construct fragment", e); } }
@Override public Fragment getItem(int position) { Fragment fragment = new NotificationListFragment();; Bundle args = new Bundle(); switch (position) { case 0: break; case 1: args.putString(NotificationListFragment.EXTRA_FILTER, "participating"); break; case 2: args.putString(NotificationListFragment.EXTRA_FILTER, "all"); break; default: throw new IllegalStateException("Item doesn't exist"); } fragment.setArguments(args); return fragment; }
@Override public void startFragmentForResult(Object receive, @NonNull Fragment fragment, int requestCode) { Bundle arguments = fragment.getArguments(); if (arguments == null) arguments = new Bundle(); Bundle receiveArgs = new Bundle(); if (receive != null) { receiveArgs.putString(BUNDLE_KEY_FOR_RESULT_RECEIVE, Rigger.getRigger(receive).getFragmentTAG()); } receiveArgs.putInt(BUNDLE_KEY_FOR_RESULT_REQUEST_CODE, requestCode); arguments.putParcelable(BUNDLE_KEY_FOR_RESULT, receiveArgs); fragment.setArguments(arguments); startFragment(fragment); }
if (fr == null) { fr = new ImagePagerFragment(); fr.setArguments(getIntent().getExtras());
@Override public Fragment getItem(int position) { Fragment fragment = null; switch (position) { case 0: fragment = defaultUser ? new UserReceivedNewsFragment() : new OrganizationNewsFragment(); break; case 1: fragment = new RepositoryListFragment(); break; case 2: fragment = defaultUser ? new MyFollowersFragment() : new MembersFragment(); break; case 3: fragment = new MyFollowingFragment(); break; } if (fragment != null) { Bundle args = new Bundle(); args.putParcelable("org", org); fragment.setArguments(args); } return fragment; }
Bundle args = new Bundle(); args.putInt(ViewPagerTabScrollViewFragment.ARG_SCROLL_Y, mScrollY); f.setArguments(args); Bundle args = new Bundle(); args.putInt(ViewPagerTabListViewFragment.ARG_INITIAL_POSITION, 1); f.setArguments(args); Bundle args = new Bundle(); args.putInt(ViewPagerTabRecyclerViewFragment.ARG_INITIAL_POSITION, 1); f.setArguments(args);
private void showFragment(@NonNull Fragment fragment, @Nullable String rootKey) { Bundle args = fragment.getArguments() == null ? new Bundle() : fragment.getArguments(); args.putString(ARG_PREFERENCE_ROOT, rootKey); fragment.setArguments(args); FragmentTransaction tx = getSupportFragmentManager() .beginTransaction() .replace(R.id.preferences_container, fragment, rootKey); if (rootKey != null) { tx.addToBackStack(null); tx.setBreadCrumbTitle(args.getInt(SCREEN_TITLE_RES)); } tx.commit(); }
private void updateFragmentView(int selection) { if (mCurrentFragment != null){ mArguments = mCurrentFragment.getArguments(); } mCurrentFragment = getFragment(selection); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); //This Activtiy (VersioningDialogActivity) contains all the file versioning parameters that have been passed from the FolderActivity in the intent extras, so we simply // pass that to the currentfragment. mCurrentFragment.setArguments(mArguments); transaction.replace(R.id.versioningFragmentContainer, mCurrentFragment); transaction.commit(); }
@Override public void onClick(View v) { final Fragment toFragment = new SubFragment(); //init your bundle first!! Bundle bundle = new Bundle(); bundle.putString("Test", "Test"); toFragment.setArguments(bundle); //You should call this method after init your argumentsBundle. FragmentTransitionLauncher .with(v.getContext()) .from(v) .prepare(toFragment); getSupportFragmentManager().beginTransaction().replace(R.id.parent_container, toFragment).addToBackStack(null).commit(); } });
/** * You should call this method after init your argumentsBundle.otherwise the transitionBundle will be not work. */ public void prepare(android.support.v4.app.Fragment toFragment) { final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap); Bundle arguments = toFragment.getArguments(); if (arguments == null) { arguments = new Bundle(); } arguments.putBundle(TRANSITION_BUNDLE, transitionBundle); toFragment.setArguments(arguments); } }
private void displayDeleteView(int position){ if(position == -1){ displayFragment(new HomeFragment(), "Home"); } else { Fragment fragment = new ManageConnectionFragment(); Bundle bundle = new Bundle(); bundle.putString(ActivityConstants.CONNECTION_KEY, connectionMap.get(position)); fragment.setArguments(bundle); Map<String, Connection> connections = Connections.getInstance(this) .getConnections(); Connection connection = connections.get(connectionMap.get(position)); displayFragment(fragment, ""); } }
private void displayView(int position){ if(position == -1){ displayFragment(new HomeFragment(), "Home"); } else { Fragment fragment = new ConnectionFragment(); Bundle bundle = new Bundle(); bundle.putString(ActivityConstants.CONNECTION_KEY, connectionMap.get(position)); fragment.setArguments(bundle); Map<String, Connection> connections = Connections.getInstance(this) .getConnections(); Connection connection = connections.get(connectionMap.get(position)); String title = connection.getId(); displayFragment(fragment, title); } }
bundle.putString(ActivityConstants.CONNECTION_KEY, connection.handle()); bundle.putBoolean(ActivityConstants.CONNECTED, true); fragment.setArguments(bundle); String title = connection.getId(); displayFragment(fragment, title);
Bundle bundle = new Bundle(); bundle.putString(ActivityConstants.CONNECTION_KEY, connection.handle()); fragment.setArguments(bundle); String title = connection.getId(); displayFragment(fragment, title);
@Override public Fragment getItem(int position) { Fragment fragment = new ColourFragment(); Bundle args = new Bundle(); args.putInt("colour", colours[position]); args.putInt("identifier", position); fragment.setArguments(args); return fragment; }