package fragment.fragmentdemo;

import android.os.Bundle;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.view.View;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}
	
    public void chooseFragment(View view) {
         Fragment frag;
         FragmentManager fragManager = getFragmentManager();
         FragmentTransaction fragTransaction = fragManager.beginTransaction();
         if(view == findViewById(R.id.buttonA)) 
             frag = new FragmentA();
         else 
             frag = new FragmentB();
         fragTransaction.replace(R.id.fragment_placeholder, frag);       
         fragTransaction.commit();
    }
}