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.chintanrathod.fragmentbackstack.MainActivity.java

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

    fragmentStack = new Stack<Fragment>();

    homeListFragment = new HomeListFragment();
    homeListFragment.registerForListener(this);

    fragmentManager = getSupportFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.add(R.id.container, homeListFragment);
    fragmentStack.push(homeListFragment);
    ft.commit();
}

From source file:com.alex.vmandroid.display.weather.inquiry.InquiryWeatherActivity.java

/**
 * ?view/*from   ww  w .  j  ava 2  s. c o m*/
 *
 * @param city ??
 */
@Override
public void initAndShowWeatherFrameLayout(@NonNull String city) {
    WeatherFragment fragment = WeatherFragment.newInstance(city);
    new WeatherPresenter(fragment, city, getApplicationContext());
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.inquiry_weather_frame_layout, fragment);
    transaction.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();
}

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

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

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

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

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

    if (savedInstanceState == null) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        LandingFragment fragment = new LandingFragment();
        transaction.replace(R.id.sample_content_fragment, fragment);
        transaction.commit();
    }/*  w ww.  java 2s . co  m*/
}

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  w ww.ja  va2  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.amsterdam.marktbureau.makkelijkemarkt.NotitiesActivity.java

/**
 *
 * @param savedInstanceState// ww w. j  a  v a  2  s.  c o m
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // get selected markt naam from sharedpreferences
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    String marktNaam = settings.getString(getString(R.string.sharedpreferences_key_markt_naam), "");

    // set the title and subtitle in the toolbar
    setToolbarTitle(getString(R.string.notities));
    setToolbarSubtitle(marktNaam);

    // add the about fragment to the container
    if (savedInstanceState == null) {
        mNotitiesFragment = new NotitiesFragment();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.container, mNotitiesFragment, NOTITIES_FRAGMENT_TAG);
        transaction.commit();
    } else {
        mNotitiesFragment = (NotitiesFragment) getSupportFragmentManager()
                .findFragmentByTag(NOTITIES_FRAGMENT_TAG);
    }

    // set the active drawer menu option
    if (mDrawerFragment.isAdded()) {
        mDrawerFragment.checkItem(mDrawerFragment.DRAWER_POSITION_NOTITIES);
    }
}

From source file:com.baoyz.dribble.BaseActivity.java

protected void addFragment(int containerId, Fragment fragment) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.add(containerId, fragment);
    transaction.commit();
}

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();//from ww w .  j  a  v a  2 s. co m
    }

    // 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.baoyz.dribble.BaseActivity.java

protected void replaceFragment(int containerId, Fragment fragment) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(containerId, fragment);
    transaction.commit();
}