List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:com.optimusinfo.elasticpath.cortex.common.EPFragmentActivity.java
/** * This method adds a fragment to the current activity * //from w w w .j a va 2s . c om * @param title * @param isNew * @param tag * @param fargmentContainerId * @param objFragment */ public void addFragmentToBreadCrumb(String title, int fargmentContainerId, EPFragment objFragment) { String breadTitle = title; if (title.length() > 16) { breadTitle = title.substring(0, 14).concat(getString(R.string.ellipsis)); } mStackLevel++; // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setBreadCrumbTitle(breadTitle); ft.replace(fargmentContainerId, objFragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.addToBackStack(null); ft.commit(); }
From source file:edu.jcu.cs470.togenda.MainActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { //refresh the current fragment. FragmentTransaction tr = getFragmentManager().beginTransaction(); if (gPosition == 0) { tr.replace(R.id.content_frame, new AgendaFragment()); } else //if not in agenda view, go to todo view. {/* w w w .j a v a2s. c om*/ tr.replace(R.id.content_frame, new ToDoFragment()); } tr.commit(); }
From source file:xyz.abcapp.dotalife.ui.Activity_Main.java
@Override protected void onCreate(final Bundle b) { super.onCreate(b); startService(new Intent(this, SensorListener.class)); if (b == null) { // Create new fragment and transaction Fragment newFragment = new Fragment_Overview(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this // fragment, // and add the transaction to the back stack transaction.replace(android.R.id.content, newFragment); // Commit the transaction transaction.commit(); }//from w w w . j a v a 2 s.co m GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this, this, this); builder.addApi(Games.API, Games.GamesOptions.builder().build()); builder.addScope(Games.SCOPE_GAMES); builder.addApi(Fitness.HISTORY_API); builder.addApi(Fitness.RECORDING_API); builder.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE)); mGoogleApiClient = builder.build(); if (!getSharedPreferences("pedometer", Context.MODE_PRIVATE).contains("timezone")) { getSharedPreferences("pedometer", Context.MODE_PRIVATE).edit() .putString("timezone", TimeZone.getDefault().getID()).commit(); } }
From source file:edu.jcu.cs470.togenda.MainActivity.java
private void selectItem(int position) { //switches to the correct fragment. Fragment newFragment;//from www. j av a2 s .com FragmentTransaction transaction = getFragmentManager().beginTransaction(); switch (position) { case 0: newFragment = new AgendaFragment(); transaction.replace(R.id.content_frame, newFragment); transaction.addToBackStack(null); transaction.commit(); gPosition = position; setTitle(pageList[position]); break; case 1: Log.d("Case1", "test"); newFragment = new ToDoFragment(); transaction.replace(R.id.content_frame, newFragment); transaction.addToBackStack(null); transaction.commit(); Log.d("Case1", "test"); gPosition = position; setTitle(pageList[position]); break; case 2: newFragment = new CalendarFragment(); transaction.replace(R.id.content_frame, newFragment); transaction.addToBackStack(null); transaction.commit(); gPosition = position; setTitle(pageList[position]); break; case 3: Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); break; } mDrawerLayout.closeDrawer(mDrawerList); }
From source file:de.sourcestream.movieDB.controller.GalleryList.java
/** * Callback method to be invoked when an item in this AdapterView has been clicked. * * @param parent The AdapterView where the click happened. * @param view The view within the AdapterView that was clicked (this will be a view provided by the adapter) * @param position The position of the view in the adapter. * @param id The row id of the item that was clicked. *//*from w ww . j a va 2 s . c o m*/ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); Bundle args = new Bundle(); args.putStringArrayList("galleryList", galleryPath); args.putInt("currPos", position); galleryPreview.setArguments(args); transaction.replace(R.id.frame_container, galleryPreview); // add the current transaction to the back stack: transaction.addToBackStack("galleryList"); transaction.commit(); }
From source file:com.sage42.androidappaddicts.app.main.MainActivity.java
public void showFragment(final Fragment fragment, final boolean addToBackstack) { final FragmentManager fragmentManager = this.getFragmentManager(); final FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.main_content_fragment, fragment); if (addToBackstack) { transaction.addToBackStack(null); } else {/*from w w w. j av a 2s .c o m*/ this.clearAllBackStack(); this.mDrawerToggle.syncState(); } transaction.commit(); // close the drawer this.mDrawerLayout.closeDrawer(this.mMenuDrawerList); }
From source file:com.sitewhere.android.example.MainActivity.java
/** * Adds the connectivity wizard if preferences have not been set. *//* ww w .j av a 2 s . c o m*/ protected void initConnectivityWizard() { FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); wizard = new ConnectivityWizardFragment(); wizard.setWizardListener(this); fragmentTransaction.replace(R.id.container, wizard); fragmentTransaction.commit(); //getActionBar().setTitle("SiteWhere Device Setup"); }
From source file:com.ternup.caddisfly.activity.MainActivity.java
/** * Display view fragment for selected nav drawer menu option *//*from w ww . j a v a 2 s . c o m*/ public void displayView(int position, boolean addToBackStack) { int index = getCurrentFragmentIndex(); if (index == position) { // requested fragment is already showing return; } Fragment fragment; showCheckUpdateOption = false; switch (position) { case Globals.HOME_SCREEN_INDEX: if (homeFragment == null) { homeFragment = new HomeFragment(); } fragment = homeFragment; break; case Globals.LOCATION_LIST_SCREEN_INDEX: if (mLocationListFragment == null) { mLocationListFragment = new LocationListFragment(); } fragment = mLocationListFragment; break; case Globals.CALIBRATE_SCREEN_INDEX: if (calibrateFragment == null) { calibrateFragment = new CalibrateFragment(); } fragment = calibrateFragment; break; case Globals.SETTINGS_SCREEN_INDEX: showCheckUpdateOption = true; if (settingsFragment == null) { settingsFragment = new SettingsFragment(); } fragment = settingsFragment; break; case Globals.HELP_SCREEN_INDEX: showCheckUpdateOption = true; if (helpFragment == null) { helpFragment = new HelpFragment(); } fragment = helpFragment; break; case Globals.ABOUT_SCREEN_INDEX: showCheckUpdateOption = true; if (aboutFragment == null) { aboutFragment = new AboutItFragment(); } fragment = aboutFragment; break; default: toggleTheme(); return; } invalidateOptionsMenu(); if (fragment != null) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); ft.replace(R.id.container, fragment, String.valueOf(position)); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); if (addToBackStack) { ft.addToBackStack(null); } ft.commit(); } mNavigationDrawerFragment.checkItem(position); }
From source file:de.linuxwhatelse.android.notify.activities.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { FragmentTransaction transaction; switch (item.getItemId()) { case R.id.navdrawer_apps: transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_container, new ApplicationsFragment()); transaction.commit(); break;// ww w. j av a2 s . co m case R.id.navdrawer_events: transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_container, new EventsPreferenceFragment()); transaction.commit(); break; case R.id.navdrawer_devices: transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_container, new ClientsFragment()); transaction.commit(); break; case R.id.navdrawer_snooze_notifications_only: case R.id.navdrawer_snooze_all_events: SnoozeDialogFragment dialog = new SnoozeDialogFragment(); if (item.getItemId() == R.id.navdrawer_snooze_notifications_only) { dialog.setTitle(getString(R.string.dialog_snooze_notifications_title)); dialog.show(getFragmentManager(), Notify.SNOOZE_NOTIFICATIONS); } else { dialog.setTitle(getString(R.string.dialog_snooze_events_title)); dialog.show(getFragmentManager(), Notify.SNOOZE_ALL); } break; case R.id.navdrawer_donate: billingProcessor = new BillingProcessor(this, Notify.GOOGLE_PLAY_LICENSE_KEY, this); break; case R.id.navdrawer_about: startActivity(new Intent(this, AboutPreferenceActivity.class)); break; case R.id.navdrawer_settings: startActivity(new Intent(this, PreferenceActivity.class)); break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer == null) return false; drawer.closeDrawer(GravityCompat.START); return true; }
From source file:org.physical_web.physicalweb.MainActivity.java
@SuppressLint("CommitTransaction") private void showFragment(Fragment newFragment, String fragmentTag, boolean addToBackStack) { FragmentTransaction transaction = getFragmentManager().beginTransaction() .setCustomAnimations(R.animator.fade_in_and_slide_up_fragment, R.animator.fade_out_fragment, R.animator.fade_in_activity, R.animator.fade_out_fragment) .replace(R.id.main_activity_container, newFragment, fragmentTag); if (addToBackStack) { transaction.addToBackStack(null); }/*from ww w . ja v a2 s .c om*/ transaction.commit(); }