Back to project page ubisoldiers.
The source code is released under:
MIT License
If you think the Android project ubisoldiers listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.gobbisanches.ubisoldiers.app; // w w w. j a va2s . c o m import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; import android.os.Bundle; /** * Created by Sanches on 13/07/2014. */ // Design Pattern: Template Method public abstract class SingleFragmentActivity extends Activity { protected abstract Fragment createFragment(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity_layout); FragmentManager fragmentManager = getFragmentManager(); Fragment fragment = fragmentManager.findFragmentById(R.id.fragmentContainer); if (fragment == null) { fragment = createFragment(); fragmentManager.beginTransaction().add(R.id.fragmentContainer, fragment).commit(); } } }