本文整理了Java中android.support.v4.app.Fragment.setArguments()
方法的一些代码示例,展示了Fragment.setArguments()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fragment.setArguments()
方法的具体详情如下:
包路径:android.support.v4.app.Fragment
类名称:Fragment
方法名:setArguments
[英]Supply the construction arguments for this fragment. This can only be called before the fragment has been attached to its activity; that is, you should call it immediately after constructing the fragment. The arguments supplied here will be retained across fragment destroy and creation.
[中]提供此片段的构造参数。这只能在片段附加到其活动之前调用;也就是说,您应该在构建片段后立即调用它。此处提供的参数将在片段销毁和创建过程中保留。
代码示例来源:origin: florent37/CameraFragment
protected static Fragment newInstance(Fragment fragment, Configuration configuration) {
Bundle args = new Bundle();
args.putSerializable(ARG_CONFIGURATION, configuration);
fragment.setArguments(args);
return fragment;
}
代码示例来源:origin: pockethub/PocketHub
@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;
}
代码示例来源:origin: pockethub/PocketHub
@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;
}
代码示例来源:origin: pockethub/PocketHub
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;
}
代码示例来源:origin: ogaclejapan/SmartTabLayout
/**
* 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;
}
代码示例来源:origin: dinuscxj/RecyclerRefreshLayout
@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);
}
}
代码示例来源:origin: pockethub/PocketHub
@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;
}
代码示例来源:origin: JingYeoh/FragmentRigger
@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);
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
if (fr == null) {
fr = new ImagePagerFragment();
fr.setArguments(getIntent().getExtras());
代码示例来源:origin: pockethub/PocketHub
@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;
}
代码示例来源:origin: ksoichiro/Android-ObservableScrollView
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);
代码示例来源:origin: jberkel/sms-backup-plus
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();
}
代码示例来源:origin: syncthing/syncthing-android
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();
}
代码示例来源:origin: takahirom/PreLollipopTransition
@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();
}
});
代码示例来源:origin: takahirom/PreLollipopTransition
/**
* 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);
}
}
代码示例来源:origin: eclipse/paho.mqtt.android
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, "");
}
}
代码示例来源:origin: eclipse/paho.mqtt.android
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);
}
}
代码示例来源:origin: eclipse/paho.mqtt.android
bundle.putString(ActivityConstants.CONNECTION_KEY, connection.handle());
bundle.putBoolean(ActivityConstants.CONNECTED, true);
fragment.setArguments(bundle);
String title = connection.getId();
displayFragment(fragment, title);
代码示例来源:origin: eclipse/paho.mqtt.android
Bundle bundle = new Bundle();
bundle.putString(ActivityConstants.CONNECTION_KEY, connection.handle());
fragment.setArguments(bundle);
String title = connection.getId();
displayFragment(fragment, title);
代码示例来源:origin: antonyt/InfiniteViewPager
@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;
}
内容来源于网络,如有侵权,请联系作者删除!