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

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

Introduction

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

Prototype

public abstract FragmentTransaction replace(int containerViewId, Fragment fragment);

Source Link

Document

Calls #replace(int,Fragment,String) with a null tag.

Usage

From source file:com.amt.slidingmenu.activity.SlidingActivity.java

private void initView() {
    mSlidingMenu = (SlidingMenu) findViewById(R.id.slidingMenu);
    mSlidingMenu.setLeftView(getLayoutInflater().inflate(R.layout.left_frame, null));
    mSlidingMenu.setRightView(getLayoutInflater().inflate(R.layout.right_frame, null));
    mSlidingMenu.setCenterView(getLayoutInflater().inflate(R.layout.center_frame, null));

    mLeftFragment = new LeftMenuFragment();
    mRightFragment = new RightDetailsFragment();
    mViewPageFragment = new ViewPageFragment();
    mViewPageFragment.setMyPageChangeListener(this);

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.left_frame, mLeftFragment);
    transaction.replace(R.id.right_frame, mRightFragment);
    transaction.replace(R.id.center_frame, mViewPageFragment);
    transaction.commit();//from   w  w  w  .j  a v  a  2 s . c o m
}

From source file:com.dwdesign.tweetings.activity.NearbyMapViewerActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_viewer);
    final Uri uri = getIntent().getData();
    if (uri == null || !AUTHORITY_NEARBY.equals(uri.getAuthority())) {
        finish();//from   w  w w  .  ja  v a 2  s.  c  o  m
        return;
    }
    final Bundle bundle = new Bundle();
    mFragment = isNativeMapSupported() ? new NativeNearbyMapFragment() : new WebMapFragment();
    mFragment.setArguments(bundle);
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.map_frame, mFragment).commit();
}

From source file:bander.notepad.PrefsActivityAppCompat.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Notepad.setAppCompatThemeFromPreferences(this, "Prefs");
    setContentView(R.layout.preferences_toolbar);

    SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this);

    ViewStub stub = (ViewStub) findViewById(R.id.toolbarWrapper);
    if (mSettings.getBoolean("darkAppCompatTheme", false))
        stub.setLayoutResource(R.layout.toolbar_dark);
    else/*from  www  . j  ava  2 s .  c  o  m*/
        stub.setLayoutResource(R.layout.toolbar_light);
    stub.inflate();
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    Notepad.setToolbarColor(this);
    setSupportActionBar(toolbar);
    if (mSettings.getBoolean("darkAppCompatTheme", false))
        toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
    else
        toolbar.setNavigationIcon(
                IconTintFactory.setDarkMaterialColor(R.drawable.abc_ic_ab_back_mtrl_am_alpha, this));

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    // Starting the Fragment
    Log.i("INFO", "Starting PreferenceFragment...");

    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    transaction.replace(R.id.prefContent, myFragment);
    transaction.commit();
}

From source file:com.android.calendar.selectcalendars.SelectVisibleCalendarsActivity.java

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

    setContentView(R.layout.simple_frame_layout);

    mController = CalendarController.getInstance(this);
    mFragment = (SelectVisibleCalendarsFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame);

    if (mFragment == null) {
        mFragment = new SelectVisibleCalendarsFragment(R.layout.calendar_sync_item);

        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.main_frame, mFragment);
        ft.show(mFragment);//from   w ww.ja va 2 s  . co  m
        ft.commit();
    }
}

From source file:com.baoyz.dribble.fragment.BaseFragment.java

protected void replaceFragment(int containerId, Fragment fragment) {
    FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    transaction.replace(containerId, fragment);
    transaction.commit();/*  www. ja v  a2 s  .co m*/
}

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

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

    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(mToolbar);//from  ww  w. ja  va2s  . c o  m
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Fragment fragment = null;
    String title = getString(R.string.app_name);
    ImageButton myImage;

    fragment = new SelectFriendFragment();
    title = getString(R.string.title_friends);

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

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

From source file:cloudbank.ble.activity.DeviceScanActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scan);

    //getSupportActionBar().setElevation(3);
    //getSupportActionBar().setTitle(R.string.app_name);

    // Sets the Toolbar to act as the ActionBar for this Activity window.
    // Make sure the toolbar exists in the activity and is not null

    // Use this check to determine whether BLE is supported on the device.  Then you can
    // selectively disable BLE-related features.
    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
        Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
        finish();/*  w  w w.  j a v  a 2s .c  om*/
    }

    // Initializes a Bluetooth adapter.  For API level 18 and above, get a reference to
    // BluetoothAdapter through BluetoothManager.
    final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter = bluetoothManager.getAdapter();

    // Checks if Bluetooth is supported on the device.
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.fragHolder, new ScanListFragment());
    ft.commit();
}

From source file:com.acrylicgoat.houstonbicyclemuseum.activity.ViewPagerActivity.java

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

    if (savedInstanceState == null) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        SlidingTabsFragment fragment = new SlidingTabsFragment();
        transaction.replace(R.id.sample_content_fragment, fragment);
        transaction.commit();//from  w  w w.  j a  va 2  s  . co m
    }
}

From source file:com.btmura.android.reddit.app.AccountListActivity.java

private void setupViews(Bundle savedInstanceState) {
    ActionBar bar = getActionBar();/*from   w  w  w .  j  av  a2s.c o m*/
    if (bar != null) {
        bar.setDisplayHomeAsUpEnabled(true);
    } else {
        ViewStub vs = (ViewStub) findViewById(R.id.button_bar_stub);
        View buttonBar = vs.inflate();

        addAccount = (Button) buttonBar.findViewById(R.id.ok);
        addAccount.setText(R.string.add_account);
        addAccount.setOnClickListener(this);

        View cancel = findViewById(R.id.cancel);
        cancel.setOnClickListener(this);
    }

    if (savedInstanceState == null) {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.account_list_container, AccountListFragment.newInstance());
        ft.commit();
    }
}

From source file:com.dahuangit.iots.app.android.activity.SlidingActivity.java

private void init() {
    mSlidingMenu = (SlidingMenu) findViewById(R.id.slidingMenu);
    mSlidingMenu.setLeftView(getLayoutInflater().inflate(R.layout.left_frame, null));
    mSlidingMenu.setRightView(getLayoutInflater().inflate(R.layout.right_frame, null));
    mSlidingMenu.setCenterView(getLayoutInflater().inflate(R.layout.center_frame, null));

    FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
    leftFragment = new LeftFragment();
    t.replace(R.id.left_frame, leftFragment);

    viewPageFragment = new ViewPageFragment();
    t.replace(R.id.center_frame, viewPageFragment);
    t.commit();//from www  .  j  a  v a 2  s  .co  m
}