Example usage for android.support.v4.app FragmentTransaction commit

List of usage examples for android.support.v4.app FragmentTransaction commit

Introduction

In this page you can find the example usage for android.support.v4.app FragmentTransaction commit.

Prototype

public abstract int commit();

Source Link

Document

Schedules a commit of this transaction.

Usage

From source file:co.vmob.sample.FragmentTabHost.java

public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
    tabSpec.setContent(new DummyTabFactory(mContext));
    final String tag = tabSpec.getTag();

    final TabInfo info = new TabInfo(tag, clss, args);

    if (mAttached) {
        // If we are already attached to the window, then check to make
        // sure this tab's fragment is inactive if it exists.  This shouldn't
        // normally happen.
        info.fragment = mFragmentManager.findFragmentByTag(tag);
        if (info.fragment != null && !info.fragment.isDetached()) {
            final FragmentTransaction ft = mFragmentManager.beginTransaction();
            ft.detach(info.fragment);// w ww.j a va 2 s . c o m
            ft.commit();
        }
    }

    mTabs.add(info);
    addTab(tabSpec);
}

From source file:com.barkside.travellocblog.MapTrip.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_trip);//from   www.j  a v  a2  s  . c  om

    // Turn on the parent navigation button in action bar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    Uri blogUri = null;
    // Display the Map as a fragment
    MapTripFragment mapFrag;
    if (savedInstanceState == null) {
        Intent intent = getIntent();

        // Get the filename from the Uri
        blogUri = intent.getData();
        Log.d(TAG, "onCreate intent uri " + blogUri);

        // First-time init; create fragment to embed in activity.
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        mapFrag = MapTripFragment.newInstance();
        ft.add(R.id.map_trip_fragment, mapFrag);
        ft.commit();
    } else {
        mapFrag = (MapTripFragment) getSupportFragmentManager().findFragmentById(R.id.map_trip_fragment);

        mBlogMgr.onRestoreInstanceState(savedInstanceState);
        blogUri = mBlogMgr.uri();
        Log.d(TAG, "onCreate savedInstanceState uri " + blogUri);
    }

    mBlogMgr.openBlog(this, blogUri, R.string.open_failed_one_file);
    mapFrag.useBlogMgr(mBlogMgr);
}

From source file:at.alladin.rmbt.android.sync.RMBTSyncFragment.java

public void populateViewForOrientation(final LayoutInflater inflater, final ViewGroup container) {
    container.removeAllViewsInLayout();//w  ww . ja  va 2s  .c  om
    final View view = inflater.inflate(R.layout.sync, container);

    final Button buttonRequestCode = (Button) view.findViewById(R.id.requestCodeButton);

    buttonRequestCode.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            final FragmentManager fm = getFragmentManager();
            FragmentTransaction ft;

            ft = fm.beginTransaction();
            ft.replace(R.id.fragment_content, new RMBTSyncRequestCodeFragment(), "sync_request_code");
            ft.addToBackStack("sync_request_code");
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            ft.commit();
        }
    });

    final Button buttonEnterCode = (Button) view.findViewById(R.id.enterCodeButton);

    buttonEnterCode.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            final FragmentManager fm = getFragmentManager();
            FragmentTransaction ft;

            ft = fm.beginTransaction();
            ft.replace(R.id.fragment_content, new RMBTSyncEnterCodeFragment(), "sync_enter_code");
            ft.addToBackStack("sync_enter_code");
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            ft.commit();
        }
    });
}

From source file:com.afg.MngProductContentProvider.Home_Activity.java

@Override
public void showManageProduct(Bundle bundle) {
    mManageProduct = ManageProduct_Fragment.getInstance(bundle);
    FragmentTransaction fr = getSupportFragmentManager().beginTransaction();
    fr.replace(R.id.fl_frameHome, mManageProduct);
    fr.addToBackStack("Manage");
    fr.commit();
}

From source file:br.com.projeto.icebeer.MainFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_refresh) {
        if (timer == null) {
            startTimer();/*  www  .  ja  va 2s  .c om*/
        } else {
            stoptimertask();
        }
        return true;
    }

    if (id == R.id.action_test) {
        TestConexaoFragment tcf = new TestConexaoFragment();
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.container, tcf);
        transaction.addToBackStack(null);

        transaction.commit();
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.agna.ferro.core.PersistentScreenScope.java

/**
 * Bind this PersistentScreenScope to screen
 * for finding this PersistentScreenScope after configuration changes should be used
 * {@link PersistentScreenScope#find(FragmentManager, String)} with same parameters
 *
 * @param screenName      name of screen
 * @param fragmentManager - fragmentManager of screen
 *///w  w  w.j a  va  2s. c  om
public void attach(FragmentManager fragmentManager, String screenName) {
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.add(this, PersistentScreenScope.getName(screenName));
    ft.commit();
}

From source file:cn.devit.app.ip_messenger.SendViewFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Log.d("main", "add user list and send bar.");
    if (userList == null) {
        FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
        userList = new UserListFragment();
        transaction.add(R.id.user_list, userList);
        sendBar = new SendBarFragment();
        transaction.add(R.id.send_bar, sendBar);
        transaction.commit();
        sendBar.setInteractionListener(listener);
    }//  w  ww  . j av  a  2s.  c  o m

}

From source file:com.anthony.app.common.widgets.fragmentNavigator.FragmentNavigator.java

/**
 * remove all fragment in the {@link FragmentManager}
 *
 * @param allowingStateLoss true if allowing state loss otherwise false
 *///w  ww .j  ava 2s . c o  m
public void removeAllFragment(boolean allowingStateLoss) {
    FragmentTransaction transaction = mFragmentManager.beginTransaction();
    removeAll(transaction);
    if (allowingStateLoss) {
        transaction.commitAllowingStateLoss();
    } else {
        transaction.commit();
    }
}

From source file:com.actionbarsherlock.sample.demos.app.ActionBarMenuSupport.java

void updateFragmentVisibility() {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    if (mCheckBox1.isChecked())
        ft.show(mFragment1);//from   ww  w  . j  a va 2  s.  co  m
    else
        ft.hide(mFragment1);
    if (mCheckBox2.isChecked())
        ft.show(mFragment2);
    else
        ft.hide(mFragment2);
    ft.commit();
}

From source file:com.ameron32.apps.tapnotes._unused.original.LoginActivity.java

/**
 * Called when the user clicked the log in button on the login form.
 *//*from w  ww  .  j a  va  2  s  .c o m*/
@Override
public void onLoginHelpClicked() {
    // Show the login help form for resetting the user's password.
    // Keep the transaction on the back stack so that if the user clicks
    // the back button, they are brought back to the login form.
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(fragmentContainer, LoginHelpFragment.newInstance(configOptions));
    transaction.addToBackStack(null);
    transaction.commit();
}