Example usage for android.app FragmentTransaction commit

List of usage examples for android.app FragmentTransaction commit

Introduction

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

Prototype

public abstract int commit();

Source Link

Document

Schedules a commit of this transaction.

Usage

From source file:it.mobistego.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_fragment);
    init();/*  ww  w .j a  va2 s  . c  o  m*/
    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.orange.ocara.ui.activity.EditCommentAudioActivity.java

@Override
protected void createAttachment() {

    android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.hide(audioPlayerFragment);
    transaction.commit();
    validateComment.setEnabled(false);/*from w  w w  .  java 2 s.  c  om*/

    // new :
    launchRecorder();

}

From source file:cn.androidy.swiftlib.navigationdrawer.NavigationDrawerActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = PlanetFragment.newInstance(position);

    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.replace(R.id.content_frame, fragment);
    ft.commit();

    // update selected item title, then close the drawer
    setTitle(mPlanetTitles[position]);//  www  .  j av  a2  s  .c om
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.orange.ocara.ui.activity.EditCommentAudioActivity.java

@Override
protected void handleAttachment() {

    if (comment.getAttachment() != null) {
        // override recordFilename value with those from comment
        audioFilename = comment.getAttachment();
    }//w  ww  .j a v  a  2  s. c o  m
    Uri audioAttachment = Uri.parse(audioFilename);
    audioPlayerFragment.setUri(audioAttachment);
    android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.show(audioPlayerFragment);
    transaction.commit();
    validateComment.setEnabled(true);

}

From source file:com.hero.fm.FileExplorerTabActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    if (USE_HTCSTYLE) {
        requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
        SetupActionBar();/*  w w w .  j a  v  a2  s  .  c o m*/
    }
    if (!USE_ACTIONBAR)
        getActionBar().hide();

    super.onCreate(savedInstanceState);

    final int rootId = 1;
    FrameLayout viewRoot = new FrameLayout(this);
    viewRoot.setId(rootId);
    setContentView(viewRoot);
    mCarousel = new Carousel();
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.add(rootId, mCarousel);
    ft.commit();
    registerForContextMenu(viewRoot);
}

From source file:org.code4hr.okcandidate.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//  w ww .  j a  va  2  s .c  o m

    if (savedInstanceState == null) {
        FragmentTransaction tx = getFragmentManager().beginTransaction();
        tx.replace(R.id.content_frame, new NeighborhoodsFragment());
        //tx.replace(R.id.content_frame, CandidateFragment.newInstance(4055));
        tx.commit();
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

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

From source file:org.peterbaldwin.vlcremote.app.PickServerActivity.java

@SuppressWarnings("unchecked")
public <T extends android.app.Fragment> T findOrReplaceFragment(int res, String tag, Class<T> fragmentClass) {
    try {//from w w w  .ja v a2s . c o  m
        FragmentManager fm = getFragmentManager();
        T fragment = (T) fm.findFragmentByTag(tag);
        if (fragment == null) {
            fragment = fragmentClass.newInstance();
            FragmentTransaction fragmentTransaction = fm.beginTransaction();
            fragmentTransaction.replace(res, fragment, tag);
            fragmentTransaction.commit();
            fm.executePendingTransactions();
        }
        return fragment;
    } catch (InstantiationException e) {
        throw new IllegalArgumentException(e);
    } catch (IllegalAccessException e) {
        throw new IllegalArgumentException(e);
    }
}

From source file:com.twp.music.LocalMusicActivity.java

private void checkedPage(LocalType type) {
    Fragment f = null;//from  ww  w .  j  a  va2 s . c o m
    showType = type;
    switch (type) {
    case ALLMUSIC:
        int count = getIntent().getIntExtra("MusicCount", 0);
        f = LocalAllMusicFragment.newInstance(count);
        break;
    case ARTISTBROWSE:
        f = LocalArtistFragment.newInstance();
        break;
    case DIRBROWSE:
        f = LocalFileFragment.newInstance();
        break;
    }
    if (null != f) {
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.content, f);
        ft.commit();
    } else {
        Logger.w("not find LocalType ,");
    }
}

From source file:com.filemanager.free.activities.Preferences.java

public void selectItem(int i) {
    switch (i) {/*w  w w  . ja va2  s  .  c  o  m*/
    case 0:
        p = new Preffrag();
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.prefsfragment, p);
        transaction.commit();
        select = 0;
        assert (getSupportActionBar()) != null;
        getSupportActionBar().setTitle(R.string.setting);
        break;
    default:
        break;
    }
}

From source file:curiosamente.com.app.activities.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    FragmentManager fm = getFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();
    MainFragment mainFragment = new MainFragment();
    fragmentTransaction.add(R.id.main_layout, mainFragment);
    fragmentTransaction.commit();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    receiver = new BroadcastReceiver() {
        @Override//w  ww.j a  va 2s .  c  o  m
        public void onReceive(Context context, Intent intent) {

            Bar[] bars = (Bar[]) intent.getExtras().get(HttpService.RETURNOBJECT_EXTRA_PROPERTY);
            //                FragmentManager fm = getFragmentManager();
            //                FragmentTransaction fragmentTransaction = fm.beginTransaction();
        }
    };

    mDrawerLayout = (DrawerLayout) findViewById(R.id.activity_main);
    mDrawerTextView = (TextView) findViewById(R.id.facebook_name_text);
    mDrawerLogoutButton = (Button) mDrawerLayout.findViewById(R.id.facebook_logout_button);
    mDrawerImage = (ImageView) findViewById(R.id.profileImage);

    Intent intent = new Intent(this, HttpService.class);
    intent.putExtra(HttpService.URL_EXTRA_PROPERTY, "http://192.168.0.13:8080/bar");
    intent.putExtra(HttpService.CLASS_EXTRA_PROPERTY, Bar[].class);
    startService(intent);

    initDrawer();
}