List of usage examples for android.support.v4.app FragmentTransaction add
public abstract FragmentTransaction add(int containerViewId, Fragment fragment, String tag);
From source file:com.edmondapps.utils.android.activity.SinglePaneActivity.java
/** * Calls {@link FragmentTransaction#add(int, Fragment, String)} if the * {@code Activity} is freshly created.<br /> * <br />//from w w w. jav a 2 s. c o m * * If the {@code Activity} is returned from an orientation change, no * {@link FragmentTransaction} will be performed. */ @Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); setContentView(onCreateLayoutId()); if (savedState == null) { mFragmentLayoutId = onCreateFragmentLayoutId(); mFragment = onCreateFragment(); if (mFragment == null) { return; } mFragmentTag = onCreateFragmentTag(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(mFragmentLayoutId, mFragment, mFragmentTag); mCalled = false; onFragmentTranscation(transaction); throwIfNotCalled(); transaction.commit(); } else { if (!savedState.containsKey(KEY_FRAGMENT_TAG) || !savedState.containsKey(KEY_FRAGMENT_LAYOUT_ID)) { throw new IllegalStateException("You must call through super.onSaveInstanceState(Bundle)."); } mFragmentTag = savedState.getString(KEY_FRAGMENT_TAG); mFragmentLayoutId = savedState.getInt(KEY_FRAGMENT_LAYOUT_ID); mFragment = getSupportFragmentManager().findFragmentByTag(mFragmentTag); } }
From source file:android.com.example.contactslist.ui.ContactDetailActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*w ww . j av a 2 s .c o m*/ protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // Enable strict mode checks when in debug modes Utils.enableStrictMode(); } super.onCreate(savedInstanceState); // This activity expects to receive an intent that contains the uri of a contact if (getIntent() != null) { // For OS versions honeycomb and higher use action bar if (Utils.hasHoneycomb()) { // Enables action bar "up" navigation getActionBar().setDisplayHomeAsUpEnabled(true); } // Fetch the data Uri from the intent provided to this activity final Uri uri = getIntent().getData(); // Checks to see if fragment has already been added, otherwise adds a new // ContactDetailFragment with the Uri provided in the intent if (getSupportFragmentManager().findFragmentByTag(TAG) == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Adds a newly created ContactDetailFragment that is instantiated with the // data Uri ft.add(android.R.id.content, ContactDetailFragment.newInstance(uri), TAG); ft.commit(); } } else { // No intent provided, nothing to do so finish() finish(); } }
From source file:br.com.mybaby.contatos.ContactDetailActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/* w ww. j av a 2s .c om*/ protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // Enable strict mode checks when in debug modes Util.enableStrictMode(); } super.onCreate(savedInstanceState); // This activity expects to receive an intent that contains the uri of a contact if (getIntent() != null) { // For OS versions honeycomb and higher use action bar if (Util.hasHoneycomb()) { // Enables action bar "up" navigation getActionBar().setDisplayHomeAsUpEnabled(false); } // Fetch the data Uri from the intent provided to this activity final Uri uri = getIntent().getData(); // Checks to see if fragment has already been added, otherwise adds a new // ContactDetailFragment with the Uri provided in the intent if (getSupportFragmentManager().findFragmentByTag(TAG) == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Adds a newly created ContactDetailFragment that is instantiated with the // data Uri ft.add(android.R.id.content, ContactDetailFragment.newInstance(uri), TAG); ft.commit(); } } else { // No intent provided, nothing to do so finish() finish(); } }
From source file:com.ces.cloudnote.app.contactslist.ContactDetailActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/* w ww .j a va 2 s . com*/ protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // Enable strict mode checks when in debug modes Utils.enableStrictMode(); } super.onCreate(savedInstanceState); // This activity expects to receive an intent that contains the uri of a contact if (getIntent() != null) { // For OS versions honeycomb and higher use action bar if (Utils.hasHoneycomb()) { // Enables action bar "up" navigation getSupportActionBar().setDisplayHomeAsUpEnabled(true); } // Fetch the data Uri from the intent provided to this activity final Uri uri = getIntent().getData(); // Checks to see if fragment has already been added, otherwise adds a new // ContactDetailFragment with the Uri provided in the intent if (getSupportFragmentManager().findFragmentByTag(TAG) == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Adds a newly created ContactDetailFragment that is instantiated with the // data Uri ft.add(android.R.id.content, ContactDetailFragment.newInstance(uri), TAG); ft.commit(); } } else { // No intent provided, nothing to do so finish() finish(); } }
From source file:com.example.android.contactslist.ui.chartActivity.ContactDetailChartActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*from w ww .j a v a 2 s .co m*/ protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // Enable strict mode checks when in debug modes Utils.enableStrictMode(); } super.onCreate(savedInstanceState); // This activity expects to receive an intent that contains the uri of a contact if (getIntent() != null) { // For OS versions honeycomb and higher use action bar if (Utils.hasHoneycomb()) { // Enables action bar "up" navigation getActionBar().setDisplayHomeAsUpEnabled(true); } // Fetch the data Uri from the intent provided to this activity final Uri uri = getIntent().getData(); // Checks to see if fragment has already been added, otherwise adds a new // ContactDetailFragment with the Uri provided in the intent if (getSupportFragmentManager().findFragmentByTag(TAG) == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Adds a newly created ContactDetailFragment that is instantiated with the // data Uri ft.add(android.R.id.content, ContactDetailChartFragment.newInstance(uri), TAG); ft.commit(); } } else { // No intent provided, nothing to do so finish() finish(); } }
From source file:com.ifeel.mt.ui.ContactDetailActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from w w w . ja v a2 s . c om protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // Enable strict mode checks when in debug modes Utils.enableStrictMode(); } super.onCreate(savedInstanceState); // This activity expects to receive an intent that contains the uri of a contact if (getIntent() != null) { // For OS versions honeycomb and higher use action bar if (Utils.hasHoneycomb()) { // Enables action bar "up" navigation getActionBar().setDisplayHomeAsUpEnabled(true); } // Fetch the data Uri from the intent provided to this activity final Uri uri = getIntent().getData(); // Checks to see if fragment has already been added, otherwise adds a new // ContactDetailFragment with the Uri provided in the intent if (getSupportFragmentManager().findFragmentByTag(TAG) == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Adds a newly created ContactDetailFragment that is instantiated with the // data Uri ft.add(android.R.id.content, ContactDetailFragment.newInstance(uri), TAG); ft.commit(); } } else { // No intent provided, nothing to do so finish() finish(); } }
From source file:com.ibuildapp.ZopimChatPlugin.ZopimChat.java
private void resumeChat() { FragmentManager manager = getSupportFragmentManager(); if (manager.findFragmentByTag(ZopimChatLogFragment.class.getName()) == null) { FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.chat_fragment_container, new ZopimChatLogFragment(), ZopimChatLogFragment.class.getName()); transaction.commit();//from w ww. j a v a2s. c o m } overDrawRightButton(); }
From source file:com.jadebyte.popularmovies.activities.MainActivity.java
public void launchDetailsFrag(@NonNull Movie movie) { MovieDetailsFragment detailsFragment = new MovieDetailsFragment(); Bundle bundle = new Bundle(); bundle.putParcelable(Constants.Keys.MOVIE_OBJECT, movie); detailsFragment.setArguments(bundle); int container = hasTwoPanes ? R.id.movie_content_details : R.id.movie_content_frame; FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.addToBackStack(null);//from www . j av a 2 s . c o m ft.add(container, detailsFragment, "MovieDetailsFragment"); ft.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right, android.R.anim.slide_in_left, android.R.anim.slide_out_right); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commitAllowingStateLoss(); }
From source file:br.com.cybereagle.androidbase.tip.TipManagerFragment.java
public void start(FragmentActivity fragmentActivity) { FragmentManager fragmentManager = fragmentActivity.getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left); fragmentTransaction.add(android.R.id.content, this, TAG); fragmentTransaction.commit();/*from w w w .j a v a 2 s . c o m*/ hidden = false; }
From source file:com.example.android.contactslist.ui.eventEntry.EventEntryActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//w w w. j a v a 2 s . com protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // Enable strict mode checks when in debug modes Utils.enableStrictMode(); } super.onCreate(savedInstanceState); // This activity expects to receive an intent that contains the uri of a contact if (getIntent() != null) { // For OS versions honeycomb and higher use action bar if (Utils.hasHoneycomb()) { // Enables action bar "up" navigation getActionBar().setDisplayHomeAsUpEnabled(true); } // Fetch the data Uri from the intent provided to this activity final Uri uri = getIntent().getData(); // Checks to see if fragment has already been added, otherwise adds a new // ContactDetailFragment with the Uri provided in the intent if (getSupportFragmentManager().findFragmentByTag(TAG) == null) { final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); // Adds a newly created EventEntryFragment that is instantiated with the // data Uri ft.add(android.R.id.content, EventEntryFragment.newInstance(uri), TAG); ft.commit(); } } else { // No intent provided, nothing to do so finish() finish(); } }