List of usage examples for android.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:com.app.avanstart.DashBoardActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new PlanetFragment(); Bundle args = new Bundle(); args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position); fragment.setArguments(args);/*from ww w .j av a 2 s . com*/ 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(mDrawerTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.example.android.adrenaland.MainActivity.java
public void selectItemSeeRidePin(boolean cloud, boolean bigDrop) { Fragment fragment = new FragmentNavigation(); Bundle args = new Bundle(); args.putBoolean(FragmentNavigation.ARG_CLOUD, cloud); args.putBoolean(FragmentNavigation.ARG_BIG_DROP, bigDrop); fragment.setArguments(args);//from w w w .j a v a2 s .c om FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.content_frame, fragment).commit(); mDrawerList.setItemChecked(1, true); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.autoparts.buyers.activity.MainDrawerActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new MainBuyerFragment(); Bundle args = new Bundle(); // args.putInt(SampleFragment.ARG_IMAGE_RES, mCityImages[position]); // args.putInt(SampleFragment.ARG_ACTION_BG_RES, R.drawable.ab_background); fragment.setArguments(args);/*from w ww . j av a 2 s .c o m*/ 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); mDrawerLayout.closeDrawer(drawer_view); }
From source file:edu.cmu.ece.ece551.uis.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment;/*from ww w . j a va 2 s . c om*/ switch (position) { default: case 0: fragment = new MasterControls(); break; case 1: fragment = new SubtractiveSynthToneControls(); break; case 2: fragment = new FMSynthToneControls(); break; case 3: fragment = new DrumMachineToneControls(); break; case 4: fragment = new PianoRollFragment(); break; case 5: fragment = new SequencerFragment(); break; } // Rotatey wheel fragment? 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(mMenuOptions[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:de.bigboot.qcircleview.cover.CoverFragment.java
@AfterViews protected void init() { Preferences preferences = new Preferences(getActivity()); FragmentManager fragMan = getChildFragmentManager(); FragmentTransaction fragTransaction = fragMan.beginTransaction(); Clock clock = preferences.getActiveClock(); if (clock == null) { clock = Clock.STATIC_CLOCKS[0]; }/* w ww.j a va2 s . co m*/ Fragment fragment; if (clock instanceof Clock.StaticClock) { Clock.StaticClock staticClock = (Clock.StaticClock) clock; fragment = staticClock.getFragment(); } else { fragment = CoverAnalogClockFragment_.builder().clock(clock).build(); } fragTransaction.add(R.id.clock_layout, fragment); fragTransaction.commit(); adapter = new CoverAdapter(getActivity()); mediaSessionListener = new MediaSessionListener(); mediaSessionManager = (MediaSessionManager) getActivity().getSystemService(Context.MEDIA_SESSION_SERVICE); try { List<MediaController> mediaControllers = mediaSessionManager .getActiveSessions(new ComponentName(getActivity(), NotificationService_.class)); adapter.onActiveSessionsChanged(mediaControllers); mediaSessionManager.addOnActiveSessionsChangedListener(mediaSessionListener, new ComponentName(getActivity(), NotificationService_.class)); } catch (SecurityException ex) { // No notification access } mViewPager.setAdapter(adapter); mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { if (position == adapter.getDefaultFragmentPosition()) { currentNotification = null; menuSlide.setPanelHeight(getResources().getDimensionPixelSize(R.dimen.menu_panel_height)); } else { currentNotification = adapter.getNotification(position); menuSlide.setPanelHeight(0); } } @Override public void onPageScrollStateChanged(int state) { } }); new SwipeDetector(mViewPager, true).setOnSwipeListener(new SwipeDetector.onSwipeEvent() { @Override public void SwipeEventDetected(View v, SwipeDetector.SwipeTypeEnum SwipeType) { if (SwipeType == SwipeDetector.SwipeTypeEnum.TOP_TO_BOTTOM && menuSlide.getPanelHeight() > 0) { menuSlide.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); } } }); }
From source file:org.adictolinux.mfcclone.MainActivity.java
private void replaceFragment(Fragment fragment, int position) { Bundle args = new Bundle(); // Guardamos la instancia de scan o reseteamos estado switch (position) { case 0:/*w w w. ja v a 2 s. com*/ case 1: case 5: scan_fragment = fragment; scan_fragment_type = position; break; default: scan_fragment = null; } args.putString(KeyProfileFragment.ARG_SECTION, getResources().getStringArray(R.array.menu_array)[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(menuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.wx.demo.MainActivity.java
void go2Fragment(Fragment fragment) { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); }
From source file:com.slim.ota.SlimOTA.java
private void addShortCutFragment() { FragmentManager fragmentManager = this.getActivity().getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); SlimLinks slimLinks = new SlimLinks(); fragmentTransaction.replace(R.id.linksFragment, slimLinks); fragmentTransaction.commit();//from www . j a v a2 s. co m }
From source file:com.areebbeigh.qrcodeutility.MainActivity.java
@Override public void setInputSection(FragmentManager fragmentManager, int inputSectionID, BaseInputFragment fragment) { fragmentManager.beginTransaction().replace(R.id.inputSection, fragment, null).commit(); }
From source file:com.jklinson.fisatarticles.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = null;//from w w w. j a v a 2 s.c o m Log.i("Selected Item", "Position =" + position); switch (position) { case 0: fragment = latestNewsFragment; Bundle args = new Bundle(); fragment.setArguments(args); break; case 1: fragment = new AboutFragment(); break; case 2: fragment = new AboutFragment(); break; case 3: fragment = new AboutFragment(); break; case 4: fragment = new AboutFragment(); break; default: break; } 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(titles[position]); mDrawerLayout.closeDrawer(mDrawerList); }