List of usage examples for android.app FragmentTransaction commit
public abstract int commit();
From source file:com.sawyer.advadapters.app.adapters.jsonadapter.UnitTestJSONArrayActivity.java
@Override protected void initFrags() { super.initFrags(); FragmentManager manager = getFragmentManager(); mListFragment = (UnitTestJSONArrayFragment) manager.findFragmentByTag(TAG_ADAPTER_FRAG); if (mListFragment == null) { mListFragment = UnitTestJSONArrayFragment.newInstance(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.frag_container, mListFragment, TAG_ADAPTER_FRAG); transaction.commit(); }/*from ww w . j a v a 2 s . c o m*/ }
From source file:com.dev.demo.activities.SlidingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sliding); if (savedInstanceState == null) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); SlidingTabFragment fragment = new SlidingTabFragment(); transaction.replace(R.id.sample_content_fragment, fragment); transaction.commit(); }//w w w. j av a 2 s .c om configureToolbar(); configureDrawer(); }
From source file:com.sawyer.advadapters.app.adapters.jsonadapter.JSONAdapterActivity.java
@Override protected void initFrags() { super.initFrags(); FragmentManager manager = getFragmentManager(); mListFragment = (JSONAdapterFragment) manager.findFragmentByTag(TAG_ADAPTER_FRAG); if (mListFragment == null) { mListFragment = JSONAdapterFragment.newInstance(); FragmentTransaction transaction = manager.beginTransaction(); transaction.replace(R.id.frag_container, mListFragment, TAG_ADAPTER_FRAG); transaction.commit(); }/*w w w . ja va 2 s . c o m*/ mAddDialogFragment = (AddJSONArrayDialogFragment) manager.findFragmentByTag(TAG_ADD_DIALOG_FRAG); if (mAddDialogFragment != null) { mAddDialogFragment.setEventListener(this); } }
From source file:org.code4hr.okcandidate.HomeActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override//w w w . j a v a 2 s .c om public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id) { case R.id.nav_survey: { FragmentTransaction tx = getFragmentManager().beginTransaction(); tx.replace(R.id.content_frame, new NeighborhoodsFragment()); tx.addToBackStack(null); tx.commit(); break; } case R.id.nav_results: { SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE); int survey_id = sharedPreferences.getInt("survey_response_id", 0); if (survey_id != 0) { FragmentTransaction tx = getFragmentManager().beginTransaction(); tx.replace(R.id.content_frame, CandidateFragment.newInstance(survey_id)); tx.addToBackStack(null); tx.commit(); } else { Toast.makeText(this, R.string.no_survey_error, Toast.LENGTH_SHORT).show(); } break; } } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.codejune.material.activities.SlidingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sliding); if (savedInstanceState == null) { FragmentTransaction transaction = getFragmentManager().beginTransaction(); SlidingTabsBasicFragment fragment = new SlidingTabsBasicFragment(); transaction.replace(R.id.sample_content_fragment, fragment); transaction.commit(); }//ww w. ja v a 2 s .co m configureToolbar(); configureDrawer(); }
From source file:org.kymjs.kjframe.ui.FrameActivity.java
/** * Fragment?/*from w w w.j ava 2 s . c om*/ * * @param resView * ?? * @param targetFragment * ??Fragment */ public void changeFragment(int resView, SupportFragment targetFragment) { android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(resView, targetFragment, targetFragment.getClass().getName()); transaction.commit(); }
From source file:it.mobistego.MainActivity.java
@Override public void onDelete() { FragmentManager ft = getFragmentManager(); FragmentTransaction tx = ft.beginTransaction(); MainFragment mainF = new MainFragment(); tx.replace(R.id.listFragment, mainF, Constants.CONTAINER); tx.commit(); }
From source file:com.tct.mail.browse.EmlViewerActivity.java
private void doCreate(Bundle savedInstanceState) { final Intent intent = getIntent(); final String action = intent.getAction(); final String type = intent.getType(); if (savedInstanceState == null) { if (Intent.ACTION_VIEW.equals(action) && MimeType.isEmlMimeType(type)) { final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.add(R.id.root, EmlMessageViewFragment.newInstance(intent.getData(), mAccountUri), FRAGMENT_TAG);//from w w w .java 2 s . co m transaction.commit(); Analytics.getInstance().sendEvent("eml_viewer", null, null, 0); } else { LogUtils.wtf(LOG_TAG, "Entered EmlViewerActivity with wrong intent action or type: %s, %s", action, type); finish(); // we should not be here. bail out. bail out. return; } } }
From source file:fr.qinder.layout.DrawerLayoutActivity.java
public void setContentFragment(String className, boolean withHistory) { DrawerLayoutFragment fragment;/*www. ja v a 2 s .co m*/ try { fragment = (DrawerLayoutFragment) Class.forName(className).newInstance(); } catch (InstantiationException e) { fragment = null; } catch (IllegalAccessException e) { fragment = null; } catch (ClassNotFoundException e) { fragment = null; } if (fragment != null) { FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(mDrawerLayoutContent, fragment); if (withHistory) { ft.addToBackStack(null); } ft.commit(); getSupportActionBar().setTitle(fragment.getTitle()); } }
From source file:com.folio3.parse.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ParseAnalytics.trackAppOpenedInBackground(getIntent()); String filePath = getApplicationContext().getFilesDir().getPath().toString() + "/" + FILE; File file = new File(filePath); try {/*w w w .j a va2s .c o m*/ if (!file.exists()) { System.out.println("Creating new file"); file.createNewFile(); } } catch (IOException ex) { ex.printStackTrace(); } /** When push message is clicked onCreate function of this activity is called */ Bundle extras = getIntent().getExtras(); if (extras != null && extras.getString(KEY_PUSH_DATA) != null) { JSONObject pushData = null; try { pushData = new JSONObject(extras.getString(KEY_PUSH_DATA)); } catch (JSONException e) { Log.e(TAG, "Unexpected JSONException when receiving push data: ", e); } String alert = null; if (pushData != null) { alert = pushData.optString("alert", null); } // Write log to the logfile if (alert != null) { writeLogToFile(getApplicationContext(), alert); FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment pushFragment = new PushFragment(); ft.replace(R.id.push_fragment, pushFragment); ft.commit(); } } }