List of usage examples for android.app FragmentTransaction replace
public abstract FragmentTransaction replace(@IdRes int containerViewId, Fragment fragment);
From source file:com.example.corppool.controller.MainActivity.java
private void showAddNewFeed() { Fragment fragment = new AddNewFeed(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the container(Main layout id) of Activity transaction.addToBackStack("newfeed"); // this will manage backstack transaction.commit();//from w w w.j a v a2 s . c om }
From source file:com.example.corppool.controller.MainActivity.java
private void showFeedresults() { Fragment fragment = new Feeds_results(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the container(Main layout id) of Activity transaction.addToBackStack("feedresults"); // this will manage backstack transaction.commit();// w w w. j av a2s. co m }
From source file:com.example.corppool.controller.MainActivity.java
private void showMyFeeds() { Fragment fragment = new MyFeeds(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the container(Main layout id) of Activity transaction.addToBackStack("feedresultsTemp"); // this will manage backstack transaction.commit();//from w ww .ja va 2s . com }
From source file:com.example.corppool.controller.MainActivity.java
public void showConfirmPage(Feed feed) { Fragment fragment = ConfirmFeedSubmit.newInstance(feed); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); // fragment container id in first parameter is the container(Main layout id) of Activity transaction.addToBackStack(null); // this will manage backstack transaction.commit();/* ww w .ja va 2s. c om*/ }
From source file:produvia.com.lights.SmartLightsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mErrorOccurred = false;/*from www . j av a 2s . c o m*/ mErrorMessage = ""; setContentView(R.layout.activity_smart_lights); listFragment = new SmartLightsFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.main_fragment, listFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); //Start running the discovery service in the background //any discovered services will be reported on the onTaskUpdate callback: if (RUN_DISCOVERY) { WeaverSdkApi.discoveryService(this, true); } //fetch the services that have already been discovered in previous scans //these services will be returned in the onTaskCompleted callback: WeaverSdkApi.servicesGet(this, null); }
From source file:es.rgmf.libresportgps.MainActivity.java
/** * This method is called when user click on track list item in the * TrackListFragment fragment.//from ww w. j a v a 2 s . c o m * * @param track * The track selected. */ @Override public void onTrackSelected(Track track) { TrackDetailFragment tdf = TrackDetailFragment.newInstance(); tdf.setTrack(track); FragmentTransaction transaction = mFragmentManager.beginTransaction(); transaction.replace(R.id.container, tdf); transaction.addToBackStack(null); // Add this fragment to stack because // the user can // back to the latter fragment. transaction.commitAllowingStateLoss(); }
From source file:es.rgmf.libresportgps.MainActivity.java
@Override public void onPostExecute() { // Dismiss the dialog progress. if (mProgressDialog != null) { mProgressDialog.dismiss();// ww w. j a v a 2s .c o m } // Load the track list fragment to refresh and load the new track. FragmentTransaction transaction = mFragmentManager.beginTransaction(); transaction.replace(R.id.container, TrackListFragment.newInstance()); mFragmentManager.popBackStack(); transaction.commitAllowingStateLoss(); // Activate the rotation screen. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); }
From source file:it.gmariotti.cardslib.demo.extras.MainActivity.java
private void openFragment(BaseFragment baseFragment) { if (baseFragment != null) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); //fragmentTransaction.setCustomAnimations(R.animator.carddemo_fag_fade_in,R.animator.carddemo_frag_fade_out); fragmentTransaction.replace(R.id.fragment_main_extras, baseFragment); //fragmentTransaction.addToBackStack(null); fragmentTransaction.commit();/*from w ww . j a v a 2 s.c o m*/ if (baseFragment.getTitleResourceId() > 0) mCurrentTitle = baseFragment.getTitleResourceId(); } }
From source file:com.jose.castsocialconnector.main.MainActivity.java
private void showConnectWarningFragment() { ConnectWarningFragment menuFragment = new ConnectWarningFragment(); menuFragment.setmMediaRouteSelector(mMediaRouteSelector); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.fragment_container, menuFragment).addToBackStack(""); transaction.commit();/*from w w w. j av a 2 s . co m*/ }
From source file:com.luan.thermospy.android.activities.MainActivity.java
@Override public void onNavigationDrawerItemSelected(int position) { // update the main content by replacing fragments onSectionAttached(position);//from www.ja va 2 s . com FragmentManager fragmentManager = getFragmentManager(); final ServerSettings serverSettings = Coordinator.getInstance().getServerSettings(); final AlarmSettings alarmSettings = Coordinator.getInstance().getAlarmSettings(); final String temperature = Coordinator.getInstance().getTemperature(); final String ip = serverSettings.getIpAddress(); final int port = serverSettings.getPort(); final boolean isAlarmSwitchChecked = alarmSettings.isAlarmSwitchEnabled(); final AlarmCondition condition = alarmSettings.getAlarmCondition(); final String alarm = alarmSettings.getAlarm(); FragmentTransaction transaction; if (position == 0) { if (ip.isEmpty() == false && port != -1) { Fragment fragment; if (isAlarmSwitchChecked) { fragment = MonitorFragment.newInstance(ip, port, alarm, temperature); } else { fragment = MonitorFragment.newInstance(ip, port, getString(R.string.not_enabled), temperature); } transaction = fragmentManager.beginTransaction().replace(R.id.container, fragment); } else { // No ip or port available. Show server setup fragment transaction = fragmentManager.beginTransaction().replace(R.id.container, SetupService.newInstance(ip, port)); } } else if (position == 1) { FragmentTransaction ft = fragmentManager.beginTransaction(); transaction = ft.replace(R.id.container, Alarm.newInstance(alarm, isAlarmSwitchChecked, Coordinator.getInstance().getServerSettings(), condition)); } else if (position == 2) { transaction = fragmentManager.beginTransaction().replace(R.id.container, SetupService.newInstance(ip, port)); } else if (position == 3) { Intent intent = new Intent(this, LogSessionActivity.class); startActivity(intent); return; } else { transaction = fragmentManager.beginTransaction(); } mLastSelected = position; transaction.commit(); }