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:com.chni.lidong.androidtestdemo.swiperefreshlistfragment.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2);
    if (savedInstanceState == null) {
        android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        SwipeRefreshListFragmentFragment fragment = new SwipeRefreshListFragmentFragment();
        transaction.replace(R.id.sample_content_fragment, fragment);
        transaction.commit();
    }/*w w  w  . j  a  va 2s.  c  om*/
}

From source file:com.appmanager.parimal.activity.MainActivity.java

private void displayView(String viewLabel, int position) {

    Fragment fragment = null;//w  w  w. ja  v  a  2  s .  co m
    String title = new String();

    fragment = new AppCategoryDetailFragment();
    Bundle arguments = new Bundle();
    arguments.putString(AppCategoryDetailFragment.ARG_ITEM_CONTENT, viewLabel);
    fragment.setArguments(arguments);
    title = viewLabel;

    if (fragment != null) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.container_body, fragment);
        fragmentTransaction.commit();

        // set the toolbar title
        getSupportActionBar().setTitle(title);
    }
}

From source file:cn.sharesdk.analysis.example.FragmentStack.java

void addFragmentToStack() {
    mStackLevel++;//  w ww  .  j a v  a  2 s  . co m

    // Instantiate a new fragment.
    Fragment newFragment = CountingFragment.newInstance(mStackLevel);

    // Add the fragment to the activity, pushing this transaction
    // on to the back stack.
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.simple_fragment, newFragment);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.addToBackStack(null);
    ft.commit();
}

From source file:cn.org.cfpamf.data.base.BaseFragment.java

protected void addBackFragment(int containerViewId, Fragment fragment) {
    FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(containerViewId, fragment);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commit();
}

From source file:MainActivity.java

public void switchFragment(View view) {
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    if (showingFragment == 1) {
        fragmentTransaction.replace(R.id.frameLayout, mFragmentTwo);
        showingFragment = 2;//from w ww  . j  a  v a 2 s.c  o m
    } else {
        fragmentTransaction.replace(R.id.frameLayout, mFragmentOne);
        showingFragment = 1;
    }
    fragmentTransaction.commit();
}

From source file:com.actionbarsherlock.whmine.book.MenuActivity.java

/** Called when the activity is first created. */
@Override//from w w  w  . ja v  a2  s  .  c  om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final ActionBar ab = getSupportActionBar();

    // set defaults for logs & home up
    ab.setDisplayHomeAsUpEnabled(showHomeUp);
    ab.setDisplayUseLogoEnabled(useLogo);

    String[] sections = getResources().getStringArray(R.array.sections);
    for (int i = 0; i < sections.length; i++) {
        ab.addTab(ab.newTab().setText(sections[i]).setTabListener(this));
    }

    // set up list nav
    ab.setListNavigationCallbacks(
            ArrayAdapter.createFromResource(this, R.array.sections, R.layout.sherlock_spinner_dropdown_item),
            new OnNavigationListener() {
                public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                    // FIXME add proper implementation
                    rotateLeftFrag();
                    return false;
                }
            });

    // default to tab navigation
    showTabsNav();

    // create a couple of simple fragments as placeholders
    final int MARGIN = 16;
    leftFrag = new RoundedColourFragment(getResources().getColor(R.color.android_green), 1f, MARGIN, MARGIN / 2,
            MARGIN, MARGIN);
    rightFrag = new RoundedColourFragment(getResources().getColor(R.color.honeycombish_blue), 2f, MARGIN / 2,
            MARGIN, MARGIN, MARGIN);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.add(R.id.root, leftFrag);
    ft.add(R.id.root, rightFrag);
    ft.commit();
}

From source file:com.anadoluuniversity.tinyreader.OcrCaptureActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *//* w w w  .j a va2  s  .  com*/
@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.ocr_capture_activity);

    DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.string.drawer_open, /* "open drawer" description */
            R.string.drawer_close /* "close drawer" description */
    );
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    getSupportActionBar()
            .setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));
    getWindow().setStatusBarColor(getResources().getColor(R.color.status_bar_color));

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    Fragment fragment = FragmentCamera.newInstance(true);
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.content_frame, fragment, "FragmentCamera");
    ft.commit();

    fillDB();

}

From source file:com.chintanrathod.fragmentbackstack.MainActivity.java

@Override
public void onItemClickedListener(String valueClicked) {
    Toast.makeText(this, valueClicked, Toast.LENGTH_LONG).show();

    FragmentTransaction ft = fragmentManager.beginTransaction();

    resultListFragment = new ResultListFragment();
    ft.add(R.id.container, resultListFragment);
    fragmentStack.lastElement().onPause();
    ft.hide(fragmentStack.lastElement());
    fragmentStack.push(resultListFragment);
    ft.commit();
}

From source file:app.android.box.waveprotocol.org.androidwave.activities.InboxActivity.java

private void displayView(int position) {
    Fragment fragment = null;//from w  ww . ja v a  2s  . co  m
    String title = getString(R.string.app_name);
    switch (position) {
    case 0:
        fragment = new InboxFragment();
        title = getString(R.string.title_home);
        break;
    case 1:
        //                fragment = new FriendsFragment();
        //                title = getString(R.string.title_friends);
        //                break;
    case 2:
        //                fragment = new MessagesFragment();
        //                title = getString(R.string.title_messages);
        //                break;
    case 3:
        //                Sign out
    default:
        break;
    }

    if (fragment != null) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.container_body, fragment);
        fragmentTransaction.commit();

        // set the toolbar title
        getSupportActionBar().setTitle(title);
    }
    /*
    toolbar = (Toolbar) findViewById(R.id.tool_bar); // Attaching the layout to the toolbar object
    setSupportActionBar(toolbar);
            
            
    FAB = (ImageButton) findViewById(R.id.imageButton);
    search = (ImageButton) findViewById(R.id.ic_search);
    //singOut = (Button) findViewById(R.id.singOut);
            
    FAB.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent openNewWavectivity = new Intent("app.android.box.waveprotocol.org.androidwave.NEWWAVEACTIVITY");
        startActivity(openNewWavectivity);
        //new wave
        //setContentView(R.layout.activity_new_wave);
    }
    });
            
    search.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent openNewWavectivity = new Intent("app.android.box.waveprotocol.org.androidwave.SEARCHACTIVITY");
        startActivity(openNewWavectivity);
        //test3
        //setC//testontentView(R.layout.activity_new_wave);
    }
    });
    */

}

From source file:at.alladin.rmbt.android.terms.RMBTTermsActivity.java

public void showNdtCheck() {
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.fragment_content, RMBTCheckFragment.newInstance(CheckType.NDT),
            AppConstants.PAGE_TITLE_NDT_CHECK);
    ft.addToBackStack(AppConstants.PAGE_TITLE_NDT_CHECK);
    ft.commit();
    setTitle(AppConstants.PAGE_TITLE_NDT_CHECK);
}