List of usage examples for android.app FragmentTransaction replace
public abstract FragmentTransaction replace(@IdRes int containerViewId, Fragment fragment);
From source file:com.kyleszombathy.sms_scheduler.AddMessage.java
/**Set up the fragment view (this is the view that everything is displayed in)*/ private void createFragmentView() { AddMessageFragment firstFragment = new AddMessageFragment(); firstFragment.setArguments(getIntent().getExtras()); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.AddMessage_FragmentContainer, firstFragment); transaction.commit();// www . j a v a 2 s . c om Log.d(TAG, "Fragment view created"); }
From source file:com.geotrackin.gpslogger.GpsMainActivity.java
/** * Handles dropdown selection//w w w.j a v a 2s . com */ @Override public boolean onNavigationItemSelected(int position, long id) { tracer.debug("Changing main view: " + String.valueOf(position)); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = prefs.edit(); editor.putInt("dropdownview", position); editor.commit(); FragmentTransaction transaction = fragmentManager.beginTransaction(); switch (position) { case 0: transaction.replace(R.id.container, GpsSimpleViewFragment.newInstance()); break; case 1: transaction.replace(R.id.container, GpsDetailedViewFragment.newInstance()); break; default: case 2: transaction.replace(R.id.container, GpsBigViewFragment.newInstance()); break; } transaction.commitAllowingStateLoss(); return true; }
From source file:fbla.hhs.eclat.Camera.Camera2BasicFragment.java
/** * Switch Fragments/*from ww w . j ava2s.co m*/ */ private void switchFrag() { ImagePreview fragment = new ImagePreview(); fragment.setImage(mFile, this, cameraType); FragmentManager fragmentManager = getActivity().getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.container, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
void addFragmentToStack() { mStackLevel++;//from ww w .j a v a 2s . co m // Instantiate a new fragment. Fragment newFragment = GetNewVehicalFragment.newInstance(GetAllVehicalDetails.this); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.animator.fragment_slide_left_enter, R.animator.fragment_slide_left_exit, R.animator.fragment_slide_right_enter, R.animator.fragment_slide_right_exit); ft.replace(R.id.fragment1, newFragment); // ft.addToBackStack(null); ft.commit(); }
From source file:iovi.testtask.MainActivity.java
private void selectItem(int position) { Fragment fragment = new ListF(); FragmentManager fragmentManager;//from w w w .j a v a2 s.c om FragmentTransaction fragmentTransaction; Bundle args = new Bundle(); args.putString("Title", mMenuTitles[position]); switch (position) { case 0: args.putString(ListF.TABLE, DataBaseHelper.TABLE_ORGANISATIONS); args.putString(ListF.COLUMN, DataBaseHelper.NAME); args.putString(ListF.SELECTION, null); args.putStringArray(ListF.ARGS, null); fragment.setArguments(args); fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); break; case 1: args.putString(ListF.TABLE, DataBaseHelper.TABLE_NEWS); args.putString(ListF.COLUMN, DataBaseHelper.NEWS_TITLE); args.putString(ListF.SELECTION, null); args.putStringArray(ListF.ARGS, null); fragment.setArguments(args); fragmentManager = getFragmentManager(); fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); break; case 2: fragment = new ContactsF(); fragment.setArguments(args); fragmentManager = getFragmentManager(); fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); break; } // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); setTitle(mMenuTitles[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
@Override public void onDataComplete(int i, String image_path) { if (i == 1) { /* Bitmap bitmap = ((BitmapDrawable)car_image.getDrawable()).getBitmap(); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes); File destination = new File(getCacheDir(),"car.jpg"); FileOutputStream fo;// www. j av a2 s. co m try { fo = new FileOutputStream(destination); fo.write(bytes.toByteArray()); fo.close(); } catch (IOException e) { e.printStackTrace(); } image_path=destination.getAbsolutePath(); // car_image.setImageBitmap(bitmap); newFragment.setImagePath(image_path);*/ } else if (i == 2) { /*car_image.setOnClickListener(null); car_image1.setOnClickListener(null);*/ // collapsingToolbarLayout.setVisibility(View.GONE); Fragment newFragment = UserAddNewVehicalSecond.newInstance(GetAllVehicalDetails.this); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.animator.fragment_slide_left_enter, R.animator.fragment_slide_left_exit, R.animator.fragment_slide_right_enter, R.animator.fragment_slide_right_exit); ft.replace(R.id.fragment1, newFragment); // ft.addToBackStack(null); ft.commit(); } else if (i == 3) { Fragment newFragment = UserAddNewVehicalThird.newInstance(GetAllVehicalDetails.this); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.animator.fragment_slide_left_enter, R.animator.fragment_slide_left_exit, R.animator.fragment_slide_right_enter, R.animator.fragment_slide_right_exit); ft.replace(R.id.fragment1, newFragment); // ft.addToBackStack(null); ft.commit(); } else if (i == 4) { Fragment newFragment = UserNewVehicalFourth.newInstance(GetAllVehicalDetails.this); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.animator.fragment_slide_left_enter, R.animator.fragment_slide_left_exit, R.animator.fragment_slide_right_enter, R.animator.fragment_slide_right_exit); ft.replace(R.id.fragment1, newFragment); // ft.addToBackStack(null); ft.commit(); } else if (i == 5) { Fragment newFragment = UserAddNewVehicalFifth.newInstance(GetAllVehicalDetails.this); // Add the fragment to the activity, pushing this transaction // on to the back stack. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.animator.fragment_slide_left_enter, R.animator.fragment_slide_left_exit, R.animator.fragment_slide_right_enter, R.animator.fragment_slide_right_exit); ft.replace(R.id.fragment1, newFragment); // ft.addToBackStack(null); ft.commit(); } else if (i == 0) { Glide.with(GetAllVehicalDetails.this).load(image_path).asBitmap() .into(new SimpleTarget<Bitmap>(300, 300) { @Override public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { //setBackgroundImage(resource); // car_image.setImageBitmap(resource); // car_image1.setImageBitmap(resource); } }); } }
From source file:org.symptomcheck.capstone.ui.MainActivityOld.java
private void openFragment(Fragment fragment, boolean addToBackStack) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (addToBackStack) { fragmentTransaction.addToBackStack(null).replace(R.id.content_frame, fragment); } else {/*from www . ja va 2s . c o m*/ fragmentTransaction.replace(R.id.content_frame, fragment); } fragmentTransaction.commit(); }
From source file:com.crearo.gpslogger.GpsMainActivity.java
private void loadFragmentView(int position) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); switch (position) { default:/*from w w w .j av a2 s . c o m*/ case 0: transaction.replace(R.id.container, GpsSimpleViewFragment.newInstance()); break; case 1: transaction.replace(R.id.container, GpsDetailedViewFragment.newInstance()); break; case 2: transaction.replace(R.id.container, GpsBigViewFragment.newInstance()); break; case 3: transaction.replace(R.id.container, GpsLogViewFragment.newInstance()); break; } transaction.commitAllowingStateLoss(); }
From source file:com.example.search.car.pools.welcome.java
public void onBackPressed() { if (canExit) { super.onBackPressed(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);//from w ww. ja v a 2 s. c o m } else { // Fragment fm = getFragmentManager().findFragmentByTag("Search"); if (frag_tag != "Search") { svg_search = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.search1); iv_search.setImageDrawable(svg_search.createPictureDrawable()); rlSearch.setBackgroundColor(Color.parseColor("#00ca98")); l_search.setBackground(getResources().getDrawable(R.drawable.white_circle_side_menu)); svg_dashboard = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.dashboard); iv_dashboard.setImageDrawable(svg_dashboard.createPictureDrawable()); rlDashboard.setBackgroundColor(Color.parseColor("#2C3E50")); l_dashboard.setBackground(getResources().getDrawable(R.drawable.search_blue)); svg_cities = SVGParser.getSVGFromResource(welcome.this.getResources(), R.raw.city); iv_cities.setImageDrawable(svg_cities.createPictureDrawable()); rlCities.setBackgroundColor(Color.parseColor("#2C3E50")); l_cities.setBackground(getResources().getDrawable(R.drawable.search_blue)); FragmentManager fm = getFragmentManager(); FragmentTransaction fragmentTransaction = fm.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, new Search()); fragmentTransaction.commit(); frag_tag = "Search"; } else { canExit = true; Toast.makeText(getApplicationContext(), "Press again to exit", Toast.LENGTH_SHORT).show(); } } mHandler.sendEmptyMessageDelayed(1, 2000/* time interval to next press in milli second */);// if not // pressed // within // 2 // seconds // then // will // be // setted(canExit) // as // false }
From source file:co.taqat.call.CallActivity.java
private void replaceFragmentVideoByAudio() { audioCallFragment = new CallAudioFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.fragmentContainer, audioCallFragment); try {/*from w ww . j a v a 2 s . com*/ transaction.commitAllowingStateLoss(); } catch (Exception e) { } }