List of usage examples for android.app FragmentManager beginTransaction
public abstract FragmentTransaction beginTransaction();
From source file:com.mediatek.engineermode.EngineerMode.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w w w. jav a 2 s . c o m final FragmentManager fragmentManager = getFragmentManager(); final FragmentTransaction transaction = fragmentManager.beginTransaction(); if (isWifiOnly()) { TAB_TITLE_IDS = TAB_TITLE_IDS_WIFIONLY; TAB_COUNT = TAB_COUNT_WIFIONLY; } Log.v("@M_" + TAG, "new fregments"); for (int i = 0; i < TAB_COUNT; i++) { mTabs[i] = new PrefsFragment(); mTabs[i].setResource(i); transaction.add(R.id.viewpager, mTabs[i], String.valueOf(i)); transaction.hide(mTabs[i]); } ViewPager viewPager; PagerTabStrip pagerTabStrip; viewPager = (ViewPager) findViewById(R.id.viewpager); pagerTabStrip = (PagerTabStrip) findViewById(R.id.pagertitle); pagerTabStrip.setTabIndicatorColorResource(android.R.color.holo_blue_light); transaction.commitAllowingStateLoss(); // fragmentManager.executePendingTransactions(); mPagerAdapter = new MyPagerAdapter(); viewPager.setAdapter(mPagerAdapter); viewPager.setCurrentItem(0); }
From source file:com.notriddle.budget.EnvelopesActivity.java
public void switchFragment(Class<?> cls, String name, Bundle args) { Fragment frag = Fragment.instantiate(this, cls.getName(), args); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, frag).addToBackStack(name) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); fragmentManager.executePendingTransactions(); configureFragment(frag);//from www .j av a 2s. c o m }
From source file:com.liferay.social.activity.MainActivity.java
public void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.main);//from ww w .ja va 2s . com _drawer = (DrawerLayout) findViewById(R.id.drawer); ListView menu = (ListView) findViewById(R.id.menu); String[] menuItems = getResources().getStringArray(R.array.menu_items); menu.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menuItems)); menu.setOnItemClickListener(this); FragmentManager manager = getFragmentManager(); Fragment fragment = manager.findFragmentByTag(UsersFragment.TAG); if (fragment == null) { FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.right_fragment, new UsersFragment(), UsersFragment.TAG); transaction.commit(); } }
From source file:com.autoparts.sellers.activity.MainDrawerActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment = new MainSellerFragment(); 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);/* w w w. j a v a 2s . c om*/ 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:com.example.android.navigationdrawerexample.activities.MainActivity.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 www . j a v a 2s. co m FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); // update selected item and title, then close the drawer drawerList.setItemChecked(position, true); setTitle(drawerTitles[position]); drawerLayout.closeDrawer(drawerList); }
From source file:com.arquitetaweb.observatorio.MainActivity.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_TYPE_GRAPH, position); fragment.setArguments(args);//from w ww . j a v a2 s .c om 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.skubit.comics.activities.MainActivity.java
private void showFragment(Fragment targetFragment, String tag, int position) { FragmentManager fm = getFragmentManager(); FragmentTransaction transaction = fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_NONE); hidesFragments(position, transaction); Fragment f = fragments[position];//from w w w .j a v a 2s. com if (f == null) { addFragmentToCache(targetFragment, tag, position); if (isFragmentInCache(tag)) { transaction.show(fragments[position]); } else { transaction.add(R.id.container, fragments[position], tag); } } else { transaction.show(fragments[position]); } transaction.commitAllowingStateLoss(); }
From source file:de.d120.ophasekistenstapeln.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments Log.d("MainActivity1", "navigation drawer item selected at position: " + position); FragmentManager fragmentManager = getFragmentManager(); switch (position) { // Countdown/* w ww . ja v a 2s.com*/ case 0: fragmentManager.beginTransaction().replace(R.id.container, new CountdownFragment()).commit(); break; // calculate case 1: fragmentManager.beginTransaction().replace(R.id.container, new CalculateFragment()).commit(); break; // highscore case 2: fragmentManager.beginTransaction().replace(R.id.container, new HighscoreFragment()).commit(); break; default: break; } onActionBarTitleUpdated(position); }
From source file:com.sopra.demo.MainActivity.java
private void selectItem(int position) { // update the main content by replacing fragments Fragment fragment;/*from w ww . ja va 2 s . c o m*/ if (position == 0) { fragment = new WebViewFragment(); } else { fragment = new MapFragment(); } Bundle args = new Bundle(); fragment.setArguments(args); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); mDrawerLayout.closeDrawer(mDrawerList); }