Android Open Source - Bluetooth-Toggling-Tool Single Fragment Activity






From Project

Back to project page Bluetooth-Toggling-Tool.

License

The source code is released under:

Apache License

If you think the Android project Bluetooth-Toggling-Tool listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.bluetooth_app;
/*from w  w w.ja  v  a  2  s  . c o  m*/

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;

public abstract class SingleFragmentActivity extends FragmentActivity {
  protected abstract Fragment createFragment();
  protected int getLayoutResId() {
    return R.layout.activity_single_fragment;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutResId());
    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragmentContainer);
    if (fragment == null) {
      fragment = createFragment();
      fm.beginTransaction()
      .add(R.id.fragmentContainer, fragment)
      .commit();
    }
    
  }
}




Java Source Code List

com.example.bluetooth_app.MainScreenActivity.java
com.example.bluetooth_app.MainScreenFragment.java
com.example.bluetooth_app.SingleFragmentActivity.java