Java Code Examples for androidx.fragment.app.fragment#setArguments()
The following examples show how to use
androidx.fragment.app.fragment#setArguments() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DevicesFragment.java From usb-serial-for-android with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void onListItemClick(ListView l, View v, int position, long id) { ListItem item = listItems.get(position-1); if(item.driver == null) { Toast.makeText(getActivity(), "no driver", Toast.LENGTH_SHORT).show(); } else { Bundle args = new Bundle(); args.putInt("device", item.device.getDeviceId()); args.putInt("port", item.port); args.putInt("baud", baudRate); args.putBoolean("withIoManager", withIoManager); Fragment fragment = new TerminalFragment(); fragment.setArguments(args); getFragmentManager().beginTransaction().replace(R.id.fragment, fragment, "terminal").addToBackStack(null).commit(); } }
Example 2
Source File: NoteEditFragment.java From Notepad with Apache License 2.0 | 6 votes |
public void onSaveDialogPositiveClick() { // User touched the dialog's positive button try { saveNote(); if(listener.isShareIntent()) finish(null); else { Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteViewFragment(); fragment.setArguments(bundle); getFragmentManager() .beginTransaction() .replace(R.id.noteViewEdit, fragment, "NoteViewFragment") .commit(); } } catch (IOException e) { // Show error message as toast if file fails to save showToast(R.string.failed_to_save); } }
Example 3
Source File: NoteListFragment.java From Notepad with Apache License 2.0 | 6 votes |
public void dispatchKeyShortcutEvent(int keyCode) { if(getId() == R.id.noteViewEdit) { switch(keyCode) { // CTRL+N: New Note case KeyEvent.KEYCODE_N: ScrollPositions.getInstance().setPosition(listView.getFirstVisiblePosition()); Bundle bundle = new Bundle(); bundle.putString("filename", "new"); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); // Add NoteEditFragment getFragmentManager() .beginTransaction() .replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE) .commit(); break; } } }
Example 4
Source File: ArticleListActivity.java From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 | 6 votes |
private void setupFragment() { FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentById(android.R.id.content); if (fragment == null) { if (mRequestParam.searchPost == 0) { fragment = new ArticleTabFragment(); } else { fragment = new ArticleSearchFragment(); } fragment.setHasOptionsMenu(true); Bundle bundle = new Bundle(); bundle.putParcelable(ParamKey.KEY_PARAM, mRequestParam); fragment.setArguments(bundle); fm.beginTransaction().replace(android.R.id.content, fragment).commit(); } else { fragment.setHasOptionsMenu(true); } }
Example 5
Source File: HierarchySecondFragment.java From WanAndroid with Apache License 2.0 | 5 votes |
public static Fragment newInstance(int id){ Bundle bundle = new Bundle(); bundle.putInt(Constant.KEY_HIERARCHY_PAGENUM, id); Fragment fragment = new HierarchySecondFragment(); fragment.setArguments(bundle); return fragment; }
Example 6
Source File: MessageDetailActivity.java From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 | 5 votes |
private void initFragment() { Fragment fragment = new MessageDetailFragment(); fragment.setHasOptionsMenu(true); Bundle bundle = new Bundle(); String url = getIntent().getDataString(); int mid; if (null != url) { mid = StringUtils.getUrlParameter(url, "mid"); } else { mid = getIntent().getIntExtra("mid", 0); } bundle.putInt("mid", mid); fragment.setArguments(bundle); getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit(); }
Example 7
Source File: FragementActivity.java From Ruisi with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FrameLayout f = new FrameLayout(this); f.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); f.setId(R.id.container); setContentView(f); Fragment to = null; Bundle b = getIntent().getExtras(); switch (b.getInt("TYPE")) { case FrageType.TOPIC: to = new FrageMyTopic(); Bundle args = new Bundle(); args.putString("username", b.getString("username")); args.putInt("uid", b.getInt("uid", 0)); to.setArguments(args); break; case FrageType.STAR: to = new FrageMyStar(); break; case FrageType.HISTORY: to = new FrageHistory(); break; default: break; } getSupportFragmentManager().beginTransaction().replace(R.id.container, to).commit(); }
Example 8
Source File: SampleFragmentContainerActivity.java From LocaleChanger with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fragment_container); if (getSupportFragmentManager().findFragmentById(getFragmentContainer()) == null) { Fragment fragment = new SampleFragment(); fragment.setArguments(getIntent().getExtras()); getSupportFragmentManager().beginTransaction().add(getFragmentContainer(), fragment).commit(); } getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
Example 9
Source File: DilbertFavoritedFragmentAdapter.java From Simple-Dilbert with Apache License 2.0 | 5 votes |
@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; }
Example 10
Source File: MainActivity.java From bitmask_android with GNU General Public License v3.0 | 5 votes |
@Override public void onBackPressed() { FragmentManagerEnhanced fragmentManagerEnhanced = new FragmentManagerEnhanced(getSupportFragmentManager()); Fragment fragment = fragmentManagerEnhanced.findFragmentByTag(MainActivity.TAG); if (fragment == null || !(fragment instanceof EipFragment)) { Fragment eipFragment = new EipFragment(); Bundle bundle = new Bundle(); bundle.putParcelable(PROVIDER_KEY, provider); eipFragment.setArguments(bundle); fragmentManagerEnhanced.replace(R.id.main_container, eipFragment, MainActivity.TAG); hideActionBarSubTitle(); } else { super.onBackPressed(); } }
Example 11
Source File: RoleRegistrationFragment.java From ridesharing-android with MIT License | 5 votes |
public static Fragment newInstance(@NonNull User user) { Fragment fragment = new RoleRegistrationFragment(); Bundle bundle = new Bundle(); bundle.putParcelable(MySharedPreferences.USER_KEY, user); fragment.setArguments(bundle); return fragment; }
Example 12
Source File: CalendarFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@NonNull @Override public Fragment getItem(int position) { if (LocaleUtils.getLocale().getLanguage().equals(new Locale("ar").getLanguage())) position = getCount() - position - 1; Fragment fragment = new YearFragment(); Bundle args = new Bundle(); args.putInt(YearFragment.YEAR, position + HijriDate.getMinHijriYear()); args.putBoolean(YearFragment.IS_HIJRI, true); fragment.setArguments(args); return fragment; }
Example 13
Source File: WeChatsFragment.java From WanAndroid with Apache License 2.0 | 5 votes |
public static Fragment newInstance(int id){ Bundle bundle = new Bundle(); bundle.putInt(Constant.KEY_WECHAT_ID, id); Fragment fragment = new WeChatsFragment(); fragment.setArguments(bundle); return fragment; }
Example 14
Source File: CalendarFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@NonNull @Override public Fragment getItem(int position) { if (LocaleUtils.getLocale().getLanguage().equals(new Locale("ar").getLanguage())) position = getCount() - position - 1; Fragment fragment = new YearFragment(); Bundle args = new Bundle(); args.putInt(YearFragment.YEAR, position + HijriDate.getMinGregYear()); args.putBoolean(YearFragment.IS_HIJRI, false); fragment.setArguments(args); return fragment; }
Example 15
Source File: ServiceBrowserFragment.java From BonjourBrowser with Apache License 2.0 | 5 votes |
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; }
Example 16
Source File: DevicesFragment.java From SimpleUsbTerminal with MIT License | 5 votes |
@Override public void onListItemClick(ListView l, View v, int position, long id) { ListItem item = listItems.get(position-1); if(item.driver == null) { Toast.makeText(getActivity(), "no driver", Toast.LENGTH_SHORT).show(); } else { Bundle args = new Bundle(); args.putInt("device", item.device.getDeviceId()); args.putInt("port", item.port); args.putInt("baud", baudRate); Fragment fragment = new TerminalFragment(); fragment.setArguments(args); getFragmentManager().beginTransaction().replace(R.id.fragment, fragment, "terminal").addToBackStack(null).commit(); } }
Example 17
Source File: ApplicationPreferencesActivity.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPreferenceClick(Preference preference) { Fragment fragment = null; switch (category) { case PREFERENCE_CATEGORY_NOTIFICATIONS: fragment = new NotificationsPreferenceFragment(); break; case PREFERENCE_CATEGORY_APP_PROTECTION: fragment = new AppProtectionPreferenceFragment(); break; case PREFERENCE_CATEGORY_APPEARANCE: fragment = new AppearancePreferenceFragment(); break; case PREFERENCE_CATEGORY_CHATS: fragment = new ChatsPreferenceFragment(); break; case PREFERENCE_CATEGORY_ADVANCED: fragment = new AdvancedPreferenceFragment(); break; case PREFERENCE_CATEGORY_HELP: startActivity(new Intent(getActivity(), LocalHelpActivity.class)); break; default: throw new AssertionError(); } if (fragment != null) { Bundle args = new Bundle(); fragment.setArguments(args); FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(android.R.id.content, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } return true; }
Example 18
Source File: MainActivity.java From bitmask_android with GNU General Public License v3.0 | 4 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data == null) { return; } if (resultCode == RESULT_OK && data.hasExtra(Provider.KEY)) { provider = data.getParcelableExtra(Provider.KEY); if (provider == null) { return; } storeProviderInPreferences(preferences, provider); ProviderObservable.getInstance().updateProvider(provider); if (!provider.supportsPluggableTransports()) { PreferenceHelper.usePluggableTransports(this, false); } navigationDrawerFragment.refresh(); switch (requestCode) { case REQUEST_CODE_SWITCH_PROVIDER: EipCommand.stopVPN(this.getApplicationContext()); break; case REQUEST_CODE_CONFIGURE_LEAP: Log.d(TAG, "REQUEST_CODE_CONFIGURE_LEAP - onActivityResult - MainActivity"); break; case REQUEST_CODE_LOG_IN: EipCommand.startVPN(this.getApplicationContext(), true); break; } } // on switch provider we need to set the EIP fragment Fragment fragment = new EipFragment(); Bundle arguments = new Bundle(); arguments.putParcelable(PROVIDER_KEY, provider); fragment.setArguments(arguments); new FragmentManagerEnhanced(getSupportFragmentManager()) .replace(R.id.main_container, fragment, EipFragment.TAG); hideActionBarSubTitle(); }
Example 19
Source File: LoginActivity.java From tindroid with Apache License 2.0 | 4 votes |
private void showFragment(String tag, Bundle args, Boolean addToBackstack) { if (isFinishing() || isDestroyed()) { return; } FragmentManager fm = getSupportFragmentManager(); Fragment fragment = fm.findFragmentByTag(tag); if (fragment == null) { switch (tag) { case FRAGMENT_LOGIN: fragment = new LoginFragment(); break; case FRAGMENT_SETTINGS: fragment = new LoginSettingsFragment(); break; case FRAGMENT_SIGNUP: fragment = new SignUpFragment(); break; case FRAGMENT_RESET: fragment = new PasswordResetFragment(); break; case FRAGMENT_CREDENTIALS: fragment = new CredentialsFragment(); break; default: throw new IllegalArgumentException(); } } if (args != null) { fragment.setArguments(args); } FragmentTransaction tx = fm.beginTransaction() .replace(R.id.contentFragment, fragment) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); if (addToBackstack) { tx = tx.addToBackStack(null); } tx.commitAllowingStateLoss(); }
Example 20
Source File: AuthenticatedWebViewFragment.java From edx-app-android with Apache License 2.0 | 4 votes |
public static Fragment newInstance(@NonNull String url, @Nullable String javascript) { final Fragment fragment = new AuthenticatedWebViewFragment(); fragment.setArguments(makeArguments(url, javascript, false)); return fragment; }