List of usage examples for android.app Fragment setArguments
public void setArguments(Bundle args)
From source file:com.nearalias.musicplayer.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments if (getFragmentManager().findFragmentById(R.id.content_frame) == null) { Fragment fragment = new PlayListFragment(); Bundle args = new Bundle(); args.putInt(PlayListFragment.ARG_PLANET_NUMBER, position); makeUpFakeSongs();/* w w w . j a va 2s .com*/ args.putStringArrayList(PlayListFragment.ARG_SONG_NAME, names); args.putStringArrayList(PlayListFragment.ARG_SONG_ARTIST, artists); args.putStringArrayList(PlayListFragment.ARG_SONG_ALBUM, albums); args.putStringArrayList(PlayListFragment.ARG_SONG_GENRE, genres); args.putStringArrayList(PlayListFragment.ARG_SONG_LYRIC, lyrics); fragment.setArguments(args); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); } // update selected item and title, then close the drawer drawerListView.setItemChecked(position, true); setTitle(planetTitles[position]); drawerLayout.closeDrawer(drawerListView); }
From source file:com.cliff.comichelper.MainActivity.java
private void selectItem(int position, boolean blank) { // update the main content by replacing fragments Fragment fragment = new WebViewFragment(); Bundle args = new Bundle(); if (blank)/*from w w w. jav a 2 s . c o m*/ args.putString(WebViewFragment.ARG_URL, "about:blank"); else args.putString(WebViewFragment.ARG_URL, "http://www.manhua8.com"); fragment.setArguments(args); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); // setTitle(mWebsiteNames[position]); mDrawerLayout.closeDrawer(mDrawerList); currentFragment = (WebViewFragment) fragment; }
From source file:com.jereksel.rommanager.MainActivity.java
public void SelectItem(final int possition) { rom = dataList.get(possition).getItemName(); // Maybe this Thread is not necessary new Thread() { public void run() { Fragment fragment; final Bundle args = new Bundle(); if (possition == 0) { fragment = new Status(); // item.setVisible(false); } else { fragment = new ROMList(); args.putString(ROMList.ROM_NAME, dataList.get(possition).getItemName()); }//from www .j a v a 2 s . c o m fragment.setArguments(args); FragmentManager frgManager = getFragmentManager(); frgManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); } }.start(); mDrawerList.setItemChecked(possition, true); setTitle(dataList.get(possition).getItemName()); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:de.anycook.einkaufszettel.activities.MainActivity.java
private void selectMenuItem(int position) { title = menuTitles[position];//from w ww . j a v a2s. c om Bundle bundle = new Bundle(); Fragment fragment; switch (position) { case 0: fragment = new GroceryListFragment(); break; case 1: fragment = new RecipeFragment(); break; case 2: fragment = new DiscoverFragment(); bundle.putString("type", "new"); break; case 3: fragment = new DiscoverFragment(); bundle.putString("type", "tasty"); break; case 4: startBrowser(); return; case 5: fragment = new SettingsFragment(); break; default: return; } fragment.setArguments(bundle); // update the main content by replacing fragments FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).addToBackStack(title).commit(); // update selected item and title, then close the drawer drawerList.setItemChecked(position, true); drawerLayout.closeDrawer(drawerList); invalidateOptionsMenu(); }
From source file:com.cgearc.yummy.Act_Main.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if (resultCode == RESULT_OK) { MyVolley.getRequestQueue().cancelAll(new RequestQueue.RequestFilter() { // clear all request @Override// www . j a v a2 s . c o m public boolean apply(com.android.volley.Request<?> request) { return true; } }); Setting.allArticles.clear(); Fragment fragment = new Frg_RecipeList(); Bundle args = new Bundle(); args.putString("query", data.getStringExtra("keyword")); args.putString("localFileId", data.getStringExtra("localFileId")); fragment.setArguments(args); String fragment_tag = getResources().getStringArray(R.array.drawer_item_array)[1] + ":" + data.getStringExtra("keyword"); this.getFragmentManager().beginTransaction().replace(R.id.content_frame, fragment, fragment_tag) .addToBackStack(null).commit(); // this.setTitle(fragment_tag); } if (resultCode == RESULT_CANCELED) { //Write your code if there's no result } } }
From source file:com.github.blalasaadri.sprinttopics.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment; Bundle args = new Bundle(); switch (navigationListIds[position]) { case "topics": fragment = new TopicsFragment(); break;/*from www .j a v a2 s . c o m*/ case "new": fragment = new NurseryRhymeFragment(); args.putSerializable(NURSERY_RHYME_ARGUMENT, NEW); break; case "old": fragment = new NurseryRhymeFragment(); args.putSerializable(NURSERY_RHYME_ARGUMENT, OLD); break; case "licenses": fragment = new LicensesFragment(); break; default: // How did we land here? fragment = new ErrorFragment(); args.putInt(ERROR_MESSAGE_ARG, R.string.navigation_error); } fragment.setArguments(args); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(navigationListItems[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.dooweb.flip.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Log.v("selectItem position", Integer.toString(position)); Fragment fragment = null; if (position == 0) { if (currentDashboard != null) fragment = currentDashboard; else//from ww w.j av a 2 s.c om fragment = new Dashboard(); currentDashboard = (Dashboard) fragment; } else if (position == 1) { fragment = new Profile(); } else if (position == 2) { fragment = new Settings(); } else if (position == 3) { fragment = new TestNotification(); } else if (position == 4) { Login.disconnect(); Intent new_intent = new Intent(MyApplication.getAppContext(), Starter.class); startActivity(new_intent); finish(); return; } else { fragment = new PlanetFragment(); Bundle args = new Bundle(); args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(args); } FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mPlanetTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.example.android.indoornavigation.activities.MainActivity.java
private void selectItem(int position) { Fragment fragment = null; FragmentManager fragmentManager;/*from w ww . j a v a2s .c om*/ if (position == 3) { // CursorLoaderListFragment cursorLoaderListFragment = new CursorLoaderListFragment(); // fragmentManager = getFragmentManager(); // fragmentManager.beginTransaction().replace(android.R.id.content, cursorLoaderListFragment).commit(); startSearchActivity(); } else if (position == 4) { startNavigationActivity(); } else { if (position == 0) { fragment = new OSMDroidMapFragment(); Bundle args = new Bundle(); args.putInt("status", 0); fragment.setArguments(args); } else if (position == 1) { fragment = new OSMDroidMapFragment(); Bundle args = new Bundle(); args.putInt("status", 1); fragment.setArguments(args); } else if (position == 2) { fragment = new OSMDroidMapFragment(); Bundle args = new Bundle(); args.putInt("status", 2); fragment.setArguments(args); } fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mNavigationDrawerTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); } }
From source file:com.cgearc.yummy.Act_Main.java
private void selectItem(int position) { String fragment_tag = getResources().getStringArray(R.array.drawer_item_array)[position]; // Google Analytics Tracker t = ((MyApplication) this.getApplication()).getTracker(); t.setScreenName(fragment_tag);//from ww w. j a v a2s . co m t.send(new HitBuilders.AppViewBuilder().build()); if (this.mSlideUpPanel != null) this.mSlideUpPanel.collapsePane(); // update the main content by replacing fragments FragmentManager fragmentManager = getFragmentManager(); Bundle args = new Bundle(); Fragment fragment = new Frg_RecipeList(); switch (position) { case 0: // Hot // mProgressBar.setVisibility(View.VISIBLE); fragmentManager.beginTransaction().addToBackStack(null) .replace(R.id.content_frame, fragment, fragment_tag).commit(); break; case 1: // Search Intent intent = new Intent(this, Act_RecipeSearch.class); this.startActivityForResult(intent, 1); break; case 2: // Favorite args.putString("favorite", "fav"); fragment.setArguments(args); fragmentManager.beginTransaction().addToBackStack(null) .replace(R.id.content_frame, fragment, fragment_tag).commit(); break; case 3: String message = "<ol>" + "<li>AppTPixnetlAev@C</li>" + "<li>Yw<a href=\"mailto://cnevinchen@gmail.com>\">gH</a></li>" + "<li>pGoA<a href='https://play.google.com/store/apps/details?id=com.cgearc.yummy'>n</a></li>" + "<li>pGwAiH<a href=\"javascript:alert(injectedObject.unistall())\"> IYummy</a></li>" + "<li>,Jemailiop,<a href=https://docs.google.com/forms/d/1Rviax0Ldl3zWkW5FwOJUYZtFALcgdbqSQdKNG3XtrN4/viewform>iI</a></li>" + "</ol>" + "<iframe src=\"https://docs.google.com/forms/d/1Rviax0Ldl3zWkW5FwOJUYZtFALcgdbqSQdKNG3XtrN4/viewform?embedded=true\" width=100% height=1300 frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\">Loading...</iframe>"; mSUPTitle.setText("App"); mSUPAuthor.setText("PA,AppNzPNHUw"); Frg_RecipeDetail detail = new Frg_RecipeDetail(); args = new Bundle(); args.putString("body", message); detail.setArguments(args); mImageButtonWeb.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.cgearc.yummy")); startActivity(i);// } }); this.getFragmentManager().beginTransaction().replace(R.id.slideUpPanel_frame, detail) .addToBackStack(null).commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub mSlideUpPanel.expandPane(); } }, 500); break; case 4: Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("https://play.google.com/store/apps/developer?id=cnevinc")); startActivity(i);// // // Strings to Show In Dialog with Radio Buttons // final CharSequence[] items = { "rY ", " Y ", " " }; // // // Creating and Building the Dialog // AlertDialog.Builder builder = new AlertDialog.Builder(this); // builder.setTitle(""); // builder.setSingleChoiceItems(items, -1, // new DialogInterface.OnClickListener() { // public void onClick(DialogInterface dialog, int item) { // // switch (item) { // case 0: // Setting.GESTURE = 0 ; // break; // case 1: // Setting.GESTURE = 1 ; // break; // case 2: // Setting.GESTURE = 2 ; // break; // } // levelDialog.dismiss(); // } // }); // levelDialog = builder.create(); // levelDialog.show(); break; } // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); // setTitle(mDrawerItems[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:ua.boberproduction.bbr.BaseActivity.java
public void openCategory(int id, String category) { // Check if there are any subcategories for the chosen category. Observable.fromCallable(() -> SQLiteStructureRepository.getInstance().getChapters(id)) .subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).doOnError((e) -> { Log.e(BBRApplication.TAG_BBR, "Error getting category list.", e); Utils.toastError(this, getString(R.string.error_loading_categories), Toast.LENGTH_SHORT); }).subscribe((categories) -> { Fragment fragment; Bundle bundle = new Bundle(); // If there are, load another ListMenuFragment. // Also, it will need the 'parent' category to put it into the actionBar's subtitle, so we're putting it into the bundle. if (categories.size() > 0) { fragment = new ListMenuFragment(); } else // If not, load content. fragment = new TextContentFragment(); // put the clicked category name into a bundle, and put the bundle into the fragment bundle.putInt(getString(R.string.tag_category_id), id); bundle.putString(getString(R.string.tag_category), category); FragmentTransaction ft = this.getFragmentManager().beginTransaction(); fragment.setArguments(bundle); //set sliding animations ft.setCustomAnimations(R.animator.slide_in_right, R.animator.slide_out_left, R.animator.slide_in_left, R.animator.slide_out_right); ft.replace(R.id.main_frame, fragment).addToBackStack(null).commit(); this.getFragmentManager().executePendingTransactions(); });/*from w w w .java2 s .c o m*/ }