private void loadSelection(int i) { switch (i) { case 0: CostOverviewFragment overviewFragment = new CostOverviewFragment(); toolbar.setTitle("Cost Overview"); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Bundle bundle = new Bundle(); bundle.putParcelable("house", house); bundle.putParcelable("account", current); bundle.putInt("cost", getIntent().getBundleExtra("extra").getInt("cost")); getIntent().putExtra("extra", bundle); fragmentTransaction.replace(R.id.detailsFragmentHolder, overviewFragment); fragmentTransaction.addToBackStack(overviewFragment.getTag()); fragmentTransaction.commit(); break; case 1: PersonalCostOverview personalCostOverview = new PersonalCostOverview(); toolbar.setTitle(cost.getSplit().get(selectedUser).getName() + "'s payments"); fragmentTransaction = fragmentManager.beginTransaction(); bundle = new Bundle(); bundle.putParcelable("house", house); bundle.putParcelable("account", current); bundle.putInt("cost", getIntent().getBundleExtra("extra").getInt("cost")); bundle.putInt("selected", selectedUser); getIntent().putExtra("extra", bundle); fragmentTransaction.replace(R.id.detailsFragmentHolder, personalCostOverview); fragmentTransaction.addToBackStack(personalCostOverview.getTag()); fragmentTransaction.commit(); break; } }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.map_view) { category = (getArguments() != null) ? getArguments().getString(SearchFragment.ARG_CATEGORY) : null; if (category != null) { MapManager.switchToMapView(category, HomeFragment.ARG_POI_CATEGORY, this); } else { ArrayList<BaseDTObject> target = new ArrayList<BaseDTObject>(); for (int i = 0; i < list.getAdapter().getCount(); i++) { BaseDTObject o = (BaseDTObject) list.getAdapter().getItem(i); target.add(o); } MapManager.switchToMapView(target, this); } return true; } else if (item.getItemId() == R.id.menu_item_addpoi) { { FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager().beginTransaction(); Fragment fragment = new CreatePoiFragment(); Bundle args = new Bundle(); args.putString(SearchFragment.ARG_CATEGORY, category); fragment.setArguments(args); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); // fragmentTransaction.detach(this); fragmentTransaction.replace(R.id.fragment_container, fragment, "pois"); fragmentTransaction.addToBackStack(fragment.getTag()); fragmentTransaction.commit(); reload = true; return true; } } else if (item.getItemId() == R.id.submenu_search) { FragmentTransaction fragmentTransaction; Fragment fragment; fragmentTransaction = getSherlockActivity().getSupportFragmentManager().beginTransaction(); fragment = new SearchFragment(); Bundle args = new Bundle(); args.putString(SearchFragment.ARG_CATEGORY, category); args.putString(CategoryHelper.CATEGORY_TYPE_POIS, CategoryHelper.CATEGORY_TYPE_POIS); if (getArguments() != null && getArguments().containsKey(SearchFragment.ARG_MY) && getArguments().getBoolean(SearchFragment.ARG_MY)) args.putBoolean(SearchFragment.ARG_MY, getArguments().getBoolean(SearchFragment.ARG_MY)); fragment.setArguments(args); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); fragmentTransaction.replace(R.id.fragment_container, fragment, "pois"); fragmentTransaction.addToBackStack(fragment.getTag()); fragmentTransaction.commit(); /* add category to bundle */ return true; } else { return super.onOptionsItemSelected(item); } }
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (id == R.id.menu_inicio) { Toast.makeText(MainActivity.this, "Funcion no disponible", Toast.LENGTH_SHORT).show(); } else if (id == R.id.menu_registrarse) { android.support.v4.app.Fragment fragment = new RegistrarseFragment(); fragmentTransaction.replace(R.id.mainFrame, fragment); fragmentTransaction.addToBackStack(null); // Toast.makeText(MainActivity.this, "Funcion no disponible", Toast.LENGTH_SHORT).show(); } else if (id == R.id.menu_iniciar_sesion) { android.support.v4.app.Fragment fragment = new LoginFragment(); fragmentTransaction.replace(R.id.mainFrame, fragment); fragmentTransaction.addToBackStack(null); } else if (id == R.id.menu_lista_recetas) { android.support.v4.app.Fragment fragment = new ListaRecetasFragment(); fragmentTransaction.replace(R.id.mainFrame, fragment); fragmentTransaction.addToBackStack(null); } else if (id == R.id.menu_lista_usuarios) { android.support.v4.app.Fragment fragment = new ListaUsuariosFragment(); fragmentTransaction.replace(R.id.mainFrame, fragment); fragmentTransaction.addToBackStack(null); // Toast.makeText(MainActivity.this, "Funcion no disponible", Toast.LENGTH_SHORT).show(); } else if (id == R.id.menu_supermercados) { Intent Intent = new Intent(this, MapsActivity.class); startActivity(Intent); // Fragment fragment = new MapsActivity(); // fragmentTransaction.replace(R.id.mainFrame, fragment); } else if (id == R.id.menu_favoritos) { Toast.makeText(MainActivity.this, "Funcion no disponible", Toast.LENGTH_SHORT).show(); } else if (id == R.id.menu_supermercados) { Toast.makeText(MainActivity.this, "Funcion no disponible", Toast.LENGTH_SHORT).show(); } else if (id == R.id.menu_ingredientes) { Toast.makeText(MainActivity.this, "Funcion no disponible", Toast.LENGTH_SHORT).show(); } else if (id == R.id.menu_cerrar_sesion) { Toast.makeText(MainActivity.this, "Funcion no disponible", Toast.LENGTH_SHORT).show(); } fragmentTransaction.commit(); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
protected void showFragment(Fragment oldFragment, Fragment newFragment) { android.support.v4.app.Fragment currentFragment = getSupportFragmentManager().findFragmentByTag(newFragment.getFragmentTag()); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); if (currentFragment != null) { if (oldFragment != null) transaction.hide(oldFragment); if (currentFragment.isDetached()) transaction.attach(currentFragment); transaction.show(currentFragment); } else { if (oldFragment != null) transaction.hide(oldFragment); if (newFragment != null) { if (newFragment.isDetached()) { transaction.attach(newFragment); } else { transaction.add(R.id.MainLayout, newFragment, newFragment.getFragmentTag()); } } } if (oldFragment != null) transaction.addToBackStack(null); transaction.commit(); }
public boolean addBackStack(FragmentTransaction ft) { if (hasBackStack()) { ft.addToBackStack(getTag()); return true; } return false; }
@Override protected void initUI() { mMiddleTv.setText(getText(R.string.the_name)); mLeftIv.setImageDrawable(getResources().getDrawable(R.drawable.ic_search)); sendClientId(); Date date = new Date(); String time = mDateFormat.format(date); String oldTime = PreferencesUtils.getValueFromSPMap( this, PreferencesUtils.Keys.TODAY, "1", PreferencesUtils.Keys.USERINFO); if (!oldTime.equals(time)) { showSign(); } else { showMakeSign(); } mTransaction = getSupportFragmentManager().beginTransaction(); mTransaction.replace(R.id.container_fragment, mFragIndex); mTransaction.addToBackStack(null); mTransaction.commit(); }
/** * @param fragmentsToInt - integer representation of fragments 0 - ExploreFragment, 1 - * SearchResultFragment, 2 - RunsFragments 3 - LaunchHistoryFragments, 4 - MyWorkflowFragment, * 5 - FavouriteWorkflowFragment * @param backStackTag */ private void beginFragmentTransaction(int[] fragmentsToInt, String backStackTag) { FragmentManager fm = parentActivity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); // ft.setCustomAnimations(R.anim.push_left_in, R.anim.push_left_out); // boolean successfullypopped = fm.popBackStackImmediate(backStackTag, 1); // if(!successfullypopped){ Fragment newFragment = new FragmentsContainer(); Bundle args = new Bundle(); args.putIntArray("fragmentsToInstantiate", fragmentsToInt); newFragment.setArguments(args); ft.addToBackStack(backStackTag); if (previousSelectedFragTag == null) { fm.beginTransaction().hide(fm.findFragmentByTag("StarterFragments")).commit(); } else { fm.beginTransaction().hide(fm.findFragmentByTag(previousSelectedFragTag)).commit(); } previousSelectedFragTag = backStackTag; ft.replace(R.id.main_panel_root, newFragment, backStackTag).commit(); // } // smooth transaction new Handler() .postDelayed( new Runnable() { public void run() { // close the menu ((MainPanelActivity) parentActivity).getMenu().toggle(); } }, 500); }
public void setMyFragment(Fragment fragment, boolean addToBackStack) { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragment_content, fragment); if (addToBackStack) ft.addToBackStack(null); ft.commit(); }
public void openFragment( Class<? extends Fragment> fragmentClazz, Bundle args, boolean addBackStack) { FragmentManager manager = getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); String tag = fragmentClazz.getName(); try { if (!isFragmentAdded(tag)) { Fragment fragment = null; fragment = fragmentClazz.newInstance(); if (args != null) { fragment.setArguments(args); } Fragment fragCurr = FragmentUtils.getCurrentFragment(this); if (fragCurr != null) transaction.hide(fragCurr); transaction.add(R.id.frameContent, fragment, tag); if (addBackStack) { transaction.addToBackStack(tag); } transaction.commit(); } else { showFragment(tag, transaction); } } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }
/** * This hook is called whenever an item in your options menu is selected. The default * implementation simply returns false to have the normal processing happen (calling the item's * Runnable or sending a message to its Handler as appropriate). You can use this method for any * items for which you would like to do processing without those other facilities. * * <p> * * <p>Derived classes should call through to the base class for it to perform the default menu * handling. * * @param item The menu item that was selected. * @return boolean Return false to allow normal menu processing to proceed, true to consume it * here. * @see #onCreateOptionsMenu */ @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id >= 0 && id < savingsAccountDataTables.size()) { DataTableDataFragment dataTableDataFragment = DataTableDataFragment.newInstance(savingsAccountDataTables.get(id), savingsAccountNumber); FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction(); fragmentTransaction.addToBackStack(FragmentConstants.FRAG_SAVINGS_ACCOUNT_SUMMARY); fragmentTransaction.replace(R.id.global_container, dataTableDataFragment); fragmentTransaction.commit(); } if (item.getItemId() == MENU_ITEM_DOCUMENTS) { loadDocuments(); } else if (id == MENU_ITEM_SEARCH) { getActivity().finish(); } return super.onOptionsItemSelected(item); }
/** * Start a new fragment containing a preference panel. If the prefences are being displayed in * multi-pane mode, the given fragment class will be instantiated and placed in the appropriate * pane. If running in single-pane mode, a new activity will be launched in which to show the * fragment. * * @param fragmentClass Full name of the class implementing the fragment. * @param args Any desired arguments to supply to the fragment. * @param titleRes Optional resource identifier of the title of this fragment. * @param titleText Optional text of the title of this fragment. * @param resultTo Optional fragment that result data should be sent to. If non-null, * resultTo.onActivityResult() will be called when this preference panel is done. The launched * panel must use {@link #finishPreferencePanel(Fragment, int, Intent)} when done. * @param resultRequestCode If resultTo is non-null, this is the caller's request code to be * received with the resut. */ public void startPreferencePanel( String fragmentClass, Bundle args, int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) { if (mSinglePane) { startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0); } else { Fragment f = Fragment.instantiate(this, fragmentClass, args); if (resultTo != null) { f.setTargetFragment(resultTo, resultRequestCode); } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.prefs, f); if (titleRes != 0) { transaction.setBreadCrumbTitle(titleRes); } else if (titleText != null) { transaction.setBreadCrumbTitle(titleText); } transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.addToBackStack(BACK_STACK_PREFS); transaction.commitAllowingStateLoss(); } }
@Override public void onThemeSelected(String themeId) { FragmentManager fm = getSupportFragmentManager(); if (!Utils.isXLarge(ThemeBrowserActivity.this)) { // show details as a fragment on top FragmentTransaction ft = fm.beginTransaction(); if (mSearchFragment != null && mSearchFragment.isVisible()) { fm.popBackStack(); } setupBaseLayout(); mDetailsFragment = ThemeDetailsFragment.newInstance(themeId); ft.add(R.id.theme_browser_container, mDetailsFragment, ThemeDetailsFragment.TAG); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(null); ft.commit(); } else { // show details as a dialog mDetailsFragment = ThemeDetailsFragment.newInstance(themeId); mDetailsFragment.show(getSupportFragmentManager(), ThemeDetailsFragment.TAG); getSupportFragmentManager().executePendingTransactions(); int minWidth = getResources().getDimensionPixelSize(R.dimen.theme_details_dialog_min_width); int height = getResources().getDimensionPixelSize(R.dimen.theme_details_dialog_height); int width = Math.max((int) (DisplayUtils.getDisplayPixelWidth(this) * 0.6), minWidth); mDetailsFragment.getDialog().getWindow().setLayout(width, height); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { FragmentManager fm = getSupportFragmentManager(); if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); setupBaseLayout(); return true; } } else if (itemId == R.id.menu_search) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if (mSearchFragment == null) { mSearchFragment = ThemeSearchFragment.newInstance(); } ft.add(R.id.theme_browser_container, mSearchFragment, ThemeSearchFragment.TAG); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(null); ft.commit(); return true; } return super.onOptionsItemSelected(item); }
private void handleListCreating(String name, boolean isList) { name = Utils.getUniqueListName(lists, name); String type = isList ? "lista" : "notatka"; ((IndexFragment) mainFragment) .getProvider() .addItem(name, (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()), type); listName = name; listId = 1; lists.add(name); Fragment fragment = isList ? PrivateListFragment.newInstance(name, listId) : NoteFragment.newInstance(name, listId); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.container, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); fragmentTransaction.commit(); setTitle(name); Log.v("start", "start"); }
// 显示详细数据 public void showDetail(int group, int child) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment fragmentdetail; Fragment heroFragment = HeroFragment.newInstance(child, fileNameHero, dirName); Fragment unitFragment = UnitFragment.newInstance(child, fileNameUnit, dirName); Fragment architectFragment = ArchitectFragment.newInstance(child, fileNameArchitect, dirName); switch (group) { case 0: fragmentdetail = heroFragment; break; case 1: fragmentdetail = unitFragment; break; case 2: fragmentdetail = architectFragment; break; default: fragmentdetail = architectFragment; break; } ft.replace(R.id.detail_undead, fragmentdetail); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(null); ft.commit(); }
/** * 收到 push 以后,打开会话页面 * * @param conversation * @param targetId * @param conversationType */ private void openConversationFragment( String conversation, String targetId, String conversationType) { String tag; if (conversation.equals("conversation")) { tag = "conversation"; ConversationFragment conversationFragment = new ConversationFragment(); Uri uri = Uri.parse("rong://" + getApplicationInfo().packageName) .buildUpon() .appendPath("conversation") .appendPath(conversationType.toLowerCase()) .appendQueryParameter("targetId", targetId) .build(); conversationFragment.setUri(uri); mConversationType = Conversation.ConversationType.valueOf(conversationType); showRealTimeLocationBar(null); // RealTimeLocation if (conversationFragment != null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.de_content, conversationFragment, tag); transaction.addToBackStack(null).commitAllowingStateLoss(); } } }
protected void replaceViewFragment( int containerResourceId, Fragment fragment, boolean addToBackStack) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction().replace(containerResourceId, fragment); if (addToBackStack) transaction.addToBackStack(null); transaction.commit(); }
/** * 消息分发,选择跳转到哪个fragment * * @param intent */ private void enterFragment(Intent intent) { String tag = null; if (intent != null) { Fragment fragment = null; if (intent.getExtras() != null && intent.getExtras().containsKey(RongConst.EXTRA.CONTENT)) { String fragmentName = intent.getExtras().getString(RongConst.EXTRA.CONTENT); fragment = Fragment.instantiate(this, fragmentName); } else if (intent.getData() != null) { if (intent.getData().getPathSegments().get(0).equals("conversation")) { tag = "conversation"; String fragmentName = ConversationFragment.class.getCanonicalName(); fragment = Fragment.instantiate(this, fragmentName); } else if (intent.getData().getLastPathSegment().equals("conversationlist")) { tag = "conversationlist"; String fragmentName = ConversationListFragment.class.getCanonicalName(); fragment = Fragment.instantiate(this, fragmentName); } else if (intent.getData().getLastPathSegment().equals("subconversationlist")) { tag = "subconversationlist"; String fragmentName = SubConversationListFragment.class.getCanonicalName(); fragment = Fragment.instantiate(this, fragmentName); SubConversationListFragment sub = (SubConversationListFragment) fragment; sub.setAdapter(new SubConversationListAdapterEx(RongContext.getInstance())); } else if (intent.getData().getPathSegments().get(0).equals("friend")) { tag = "friend"; String fragmentName = FriendMultiChoiceFragment.class.getCanonicalName(); fragment = Fragment.instantiate(this, fragmentName); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); // 隐藏ActionBar } targetId = intent.getData().getQueryParameter("targetId"); targetIds = intent.getData().getQueryParameter("targetIds"); mDiscussionId = intent.getData().getQueryParameter("discussionId"); if (targetId != null) { mConversationType = Conversation.ConversationType.valueOf( intent.getData().getLastPathSegment().toUpperCase(Locale.getDefault())); } else if (targetIds != null) { mConversationType = Conversation.ConversationType.valueOf( intent.getData().getLastPathSegment().toUpperCase(Locale.getDefault())); } } if ("tag".equals(tag)) { showRealTimeLocationBar(null); // RealTimeLocation } if (fragment != null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.de_content, fragment, tag); transaction.addToBackStack(null).commitAllowingStateLoss(); } } }
/** 设置登陆界面 已登陆:我的课表+我的资料 未登陆:登陆+注册 登陆状态改变时更新menudrawer的菜单显示 */ public void setLoginedFragment(String username) { this.username = username; mloginFragment = new HomeFragment(); if (username == null || "".equals(username)) { mloginFragment.addpager("登陆", new LoginFragment()); mloginFragment.addpager("注册", new RegistFragment()); SharedPreferences sp = getPreferences(0); Editor edit = sp.edit(); edit.putBoolean("autologin", false); edit.commit(); autologin = false; settingAdapter.setTitle0("登陆"); settingAdapter.setTitle("登陆"); } else { mloginFragment.addpager("我的课表", new MyCourseFragment()); mloginFragment.addpager("我的资料", new MyInfoFragment()); settingAdapter.setTitle0(username); settingAdapter.setTitle(username); } FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.container, mloginFragment); ft.addToBackStack(null); ft.commit(); // settingAdapter.notifyDataSetChanged();//无法及时改变状态,不知道为什么 - - // settingAdapter.notifyDataSetInvalidated(); }
@Override public void run() { Fragment newFragment = new DashboardFragment( mContext, businessListVector.get(listPosition), returnListModel, mDrawerLayout, businesslist, listPosition, test); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.anim.abc_popup_enter, R.anim.abc_popup_exit); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack if needed transaction.replace(R.id.wholevertical, newFragment); transaction.addToBackStack(FragmentNameConfig.DASHBOARD_FRAGMENT); try { transaction.commit(); } catch (IllegalStateException e) { } // Commit the transaction //// TODO: 11/11/2015 }
private void hideListItemsMenu(View v, boolean close) { boolean toBeHidden = false; for (int index = 0; index < list.getChildCount(); index++) { View view = list.getChildAt(index); if (view instanceof ViewSwitcher && ((ViewSwitcher) view).getDisplayedChild() == 1) { ((ViewSwitcher) view).showPrevious(); toBeHidden = true; getPoiAdapter().setElementSelected(-1); postitionSelected = -1; } } if (!toBeHidden && v != null && v.getTag() != null && !close) { // no items needed to be flipped, fill and open details page FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager().beginTransaction(); PoiDetailsFragment fragment = new PoiDetailsFragment(); Bundle args = new Bundle(); args.putString(PoiDetailsFragment.ARG_POI_ID, ((PoiPlaceholder) v.getTag()).poi.getId()); fragment.setArguments(args); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); // fragmentTransaction.detach(this); fragmentTransaction.replace(R.id.fragment_container, fragment, "pois"); fragmentTransaction.addToBackStack(fragment.getTag()); fragmentTransaction.commit(); } }
private void addOrgDetailsFragment(String id) { listClick = false; mDrawerLayout.closeDrawer(businesslistlayout); refresh.setVisibility(View.GONE); businesslistview.setVisibility(View.GONE); DashBoardTitle.setText("ADD EXEMPT ORGANIZATION DETAILS"); Fragment newFragment = new AddExemptOrganization(mContext, fromDashboard, false); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.anim.slidein, R.anim.slideout); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack if needed transaction.replace(R.id.wholevertical, newFragment); transaction.addToBackStack(FragmentNameConfig.ORG_DETAIL_FRAGMENT); // Commit the transaction transaction.commit(); }
/** * Callback method from {@link PaperListFragment.Callbacks} indicating that the item with the * given ID was selected. */ @Override public void onItemSelected(String id) { noteId = id; if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle arguments = new Bundle(); arguments.putString(PaperDetailFragment.ARG_ITEM_ID, id); PaperDetailFragment fragment = new PaperDetailFragment(); fragment.setArguments(arguments); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.note_detail_container, fragment); if (getIntent().getAction().equals(Intent.ACTION_VIEW)) ft.addToBackStack(null); ft.commit(); } else { // In single-pane mode, simply start the detail activity // for the selected item ID. Intent detailIntent = new Intent(this, PaperDetailActivity.class); detailIntent.putExtra(PaperDetailFragment.ARG_ITEM_ID, id); startActivityForResult(detailIntent, DETAIL_NOTE); } }
private void TaxPageFragment(String id) { mDrawerLayout.closeDrawer(businesslistlayout); refresh.setVisibility(View.GONE); businesslistview.setVisibility(View.GONE); DashBoardTitle.setText("ADD EXEMPT ORGANIZATION DETAILS"); AppConfigManager.saveFlag(mContext, 0); Fragment newFragment = new CommonTaxFragment(mContext); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.anim.slidein, R.anim.slideout); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack if needed transaction.replace(R.id.wholevertical, newFragment); transaction.addToBackStack(FragmentNameConfig.FORM_TAX_SELECTION_FRAGMENT); // Commit the transaction transaction.commit(); }
public void switchTo(Class className, Bundle bundle, String tag) { FragmentTransaction ft = fm.beginTransaction(); Fragment mFragement = SherlockFragment.instantiate(this, className.getName(), bundle); ft.replace(R.id.layout_container, mFragement, tag); ft.addToBackStack(null); ft.commit(); }
public void onListViewClick(View view) { FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Fragment listFragment = new ItemFragment(); fragmentTransaction.replace(R.id.fragment_container, listFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); }
private void replaceFragment(Fragment fragment) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit); ft.replace(R.id.content_view, fragment, fragment.getClass().getSimpleName()); ft.addToBackStack(null); ft.commit(); }
/** Instantiate and show the Picker */ public void show() { if (manager == null || styleResId == null) { Log.e("NumberPickerBuilder", "setFragmentManager() and setStyleResId() must be called."); return; } final FragmentTransaction ft = manager.beginTransaction(); final Fragment prev = manager.findFragmentByTag("number_dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); final NumberPickerDialogFragment fragment = NumberPickerDialogFragment.newInstance( mReference, styleResId, minNumber, maxNumber, plusMinusVisibility, decimalVisibility, labelText, currentNumberValue, currentDecimalValue, currentSignValue); if (targetFragment != null) { fragment.setTargetFragment(targetFragment, 0); } fragment.setNumberPickerDialogHandlers(mNumberPickerDialogHandlers); fragment.setNumberPickerDialogHandlersV2(mNumberPickerDialogHandlersV2); fragment.show(ft, "number_dialog"); }
/* (non-Javadoc) * @see uk.ac.swan.digitaltrails.fragments.SearchListFragment.OnWalkSelectedListener#onWalkSelected(uk.ac.swan.digitaltrails.components.Walk) */ @Override public void onWalkSelected(Walk walk) { Log.d(TAG, "Trying to choose a walk"); SearchDetailsFragment detailsFrag = (SearchDetailsFragment) getSupportFragmentManager().findFragmentById(R.id.search_details_fragment); mWalk = walk; if (detailsFrag != null) { Log.d(TAG, "In 2 pane view"); // if available and we are in 2-pane view. detailsFrag.updateDetailsView(walk); } else { Log.d(TAG, "In 1 pane view"); // if in 1 pane view SearchDetailsFragment newDetailsFragment = new SearchDetailsFragment(); Bundle args = new Bundle(); args.putParcelable(SearchDetailsFragment.ARG_POSITION, walk); newDetailsFragment.setArguments(args); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_container, newDetailsFragment); transaction.addToBackStack(null); transaction.commit(); } }
public void onArticleSelected(int position) { // Cargamos el fragmento que muestra el contenido del artículo para reemplazar su texto ArticleFragment articleFrag = (ArticleFragment) getSupportFragmentManager().findFragmentById(R.id.article_fragment); if (articleFrag != null) { // Si el fragmento artículo existe, reemplazamos el texto articleFrag.updateArticleView(position); } else { // Si el fragmento no está disponible hemos de ejecutar la transacción de reemplazar // la vista. ArticleFragment newFragment = new ArticleFragment(); Bundle args = new Bundle(); args.putInt(ArticleFragment.ARG_POSITION, position); newFragment.setArguments(args); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack(null); // Commit transaction.commit(); } }