List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:com.liferay.social.activity.MainActivity.java
public void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.main);//from w w w . j a va 2 s.c o m _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.brandao.tictactoe.board.BoardActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.board_activity); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.board_activity_coordinator_layout); mToolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(mToolbar);/*from w w w. j av a 2s. com*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); mBoardFragment = (BoardFragment) getFragmentManager().findFragmentByTag(FRAGMENT_TAG_BOARD); if (mBoardFragment == null) { FragmentTransaction t = getFragmentManager().beginTransaction(); mBoardFragment = BoardFragment.newInstance(); t.replace(R.id.board_fragment_container, mBoardFragment, FRAGMENT_TAG_BOARD); t.commit(); } }
From source file:ca.farrelltonsolar.uicomponents.TabStripAdapter.java
/** * Update an existing tab. Make sure to call {@link #notifyTabsChanged} afterwards. *//*from www . j a v a 2 s . c o m*/ public void updateTab(int titleRes, Class<?> fragmentClass, Bundle args, int position) { if (position >= 0 && position < tabs.size()) { // update tab info tabs.set(position, new TabInfo(position, fragmentClass, args, titleRes)); // find current fragment of tab Fragment oldFragment = fragmentManager .findFragmentByTag(makeFragmentName(viewPager.getId(), getItemId(position))); // remove it FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.remove(oldFragment); transaction.commit(); fragmentManager.executePendingTransactions(); } }
From source file:tw.example.robert.myapplication.bluetoothchat.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = new Intent(this, LocationService.class); startService(intent);/*from w ww . j a va2s .c o m*/ if (savedInstanceState == null) { FragmentManager ft = getFragmentManager(); FragmentTransaction transaction = ft.beginTransaction(); BluetoothChatFragment fragment = new BluetoothChatFragment(); transaction.replace(R.id.sample_content_fragment, fragment); transaction.commit(); } }
From source file:com.sawyer.advadapters.app.adapters.nfjsonadapter.NFJSONAdapterActivity.java
@Override protected void initFrags() { super.initFrags(); FragmentManager manager = getFragmentManager(); mListFragment = (NFJSONAdapterFragment) manager.findFragmentByTag(TAG_ADAPTER_FRAG); if (mListFragment == null) { mListFragment = NFJSONAdapterFragment.newInstance(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.frag_container, mListFragment, TAG_ADAPTER_FRAG); transaction.commit(); }/*from w w w. j a v a2 s . c o m*/ mAddDialogFragment = (AddJSONArrayDialogFragment) manager.findFragmentByTag(TAG_ADD_DIALOG_FRAG); if (mAddDialogFragment != null) { mAddDialogFragment.setEventListener(this); } }
From source file:com.harsh.androidclientphpbackend.fragment.ProfileFragment.java
private void goToLogin() { Fragment login = new LoginFragment(); FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.fragment_frame, login); ft.commit(); }
From source file:com.example.kyle.fragmentexample.MainActivity.java
public void replaceFragment(Fragment fragment) { FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); transaction.replace(R.id.fragment_container, fragment); transaction.addToBackStack(null);//from w ww. ja va 2s .c om transaction.commit(); }
From source file:com.tortel.deploytrack.SettingsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // Check for light theme Prefs.load(this); if (Prefs.useLightTheme()) { setTheme(R.style.Theme_DeployThemeLight); }//w w w .j a v a2s. co m super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.content_frame, new SettingsFragment()); transaction.commit(); }
From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java
private void loadPrefFragment(PreferenceFragment fragment, @StringRes int titleBarName) { FragmentTransaction t = getFragmentManager().beginTransaction(); t.replace(R.id.prefsfragment, fragment); t.commit(); getSupportActionBar().setTitle(titleBarName); }
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.video.SignSearchVideoActivity.java
private void showSignVideoFragment(SignVideoFragment signVideoFragment) { final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.searchVideoActivityContentFrame, signVideoFragment, "SIGN_VIDEO_TAG"); transaction.addToBackStack(null);/*from w ww.j ava 2 s. c om*/ transaction.commit(); }