Search in sources :

Example 41 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project android-support-v4-googlemaps by petedoyle.

the class FragmentStackFragmentSupport method addFragmentToStack.

void addFragmentToStack() {
    mStackLevel++;
    // Instantiate a new fragment.
    Fragment newFragment = FragmentStackSupport.CountingFragment.newInstance(mStackLevel);
    // Add the fragment to the activity, pushing this transaction
    // on to the back stack.
    FragmentTransaction ft = getChildFragmentManager().beginTransaction();
    ft.replace(R.id.simple_fragment, newFragment);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.addToBackStack(null);
    ft.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Fragment(android.support.v4.app.Fragment)

Example 42 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project android-support-v4-googlemaps by petedoyle.

the class FragmentArgumentsSupport method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_arguments_support);
    if (savedInstanceState == null) {
        // First-time init; create fragment to embed in activity.
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        Fragment newFragment = MyFragment.newInstance("From Arguments");
        ft.add(R.id.created, newFragment);
        ft.commit();
    }
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Fragment(android.support.v4.app.Fragment)

Example 43 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project mobile-android by photo.

the class SyncFragment method detachActiveFragment.

public void detachActiveFragment() {
    if (activeFragment != null && !instanceSaved && !getActivity().isFinishing()) {
        FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
        transaction.detach(activeFragment);
        transaction.commit();
    // activeFragment = null;
    }
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 44 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project mobile-android by photo.

the class SyncFragment method selectFragment.

void selectFragment(Fragment fragment, boolean attachOnly) {
    CommonUtils.debug(TAG, "Selecting fragment: " + fragment + "; attachOnly: " + attachOnly);
    if (getActivity() == null) {
        CommonUtils.debug(TAG, "Fragment is no more attached to activity.");
        return;
    }
    FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
    if (activeFragment != null && !activeFragment.isDetached()) {
        transaction.detach(activeFragment);
    }
    if (attachOnly) {
        transaction.attach(fragment);
    } else {
        transaction.replace(R.id.fragment_container, fragment, getTagForFragment(fragment));
    }
    transaction.commit();
    activeFragment = fragment;
    activeFragment.setMenuVisibility(mMenuVisible);
    activeFragment.setUserVisibleHint(mUserVisibleHint);
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 45 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project android by owncloud.

the class FileDisplayActivity method setSecondFragment.

/**
     * Replaces the second fragment managed by the activity with the received as
     * a parameter.
     * <p/>
     * Assumes never will be more than two fragments managed at the same time.
     *
     * @param fragment New second Fragment to set.
     */
private void setSecondFragment(Fragment fragment) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.right_fragment_container, fragment, TAG_SECOND_FRAGMENT);
    transaction.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction)

Aggregations

FragmentTransaction (android.support.v4.app.FragmentTransaction)392 Fragment (android.support.v4.app.Fragment)135 FragmentManager (android.support.v4.app.FragmentManager)79 View (android.view.View)29 DialogFragment (android.support.v4.app.DialogFragment)27 FragmentActivity (android.support.v4.app.FragmentActivity)25 Bundle (android.os.Bundle)21 TextView (android.widget.TextView)19 FragmentTransaction (android.app.FragmentTransaction)18 Intent (android.content.Intent)18 Button (android.widget.Button)17 OnClickListener (android.view.View.OnClickListener)16 SherlockFragment (com.actionbarsherlock.app.SherlockFragment)12 ActionBar (android.support.v7.app.ActionBar)8 TargetApi (android.annotation.TargetApi)6 AppCompatActivity (android.support.v7.app.AppCompatActivity)6 Toolbar (android.support.v7.widget.Toolbar)6 FriendsTimeLineFragment (org.qii.weiciyuan.ui.maintimeline.FriendsTimeLineFragment)6 UserInfoFragment (org.qii.weiciyuan.ui.userinfo.UserInfoFragment)6 Transition (android.transition.Transition)5