package com.example.kechengbiao;

import android.app.Activity;
import android.app.Application;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.SharedPreferences;
import android.os.Bundle;
/**
 * 所有activity得基类
 * 封装了application，SharedPreferences sp
 * @author 超超boy
 *
 */
public abstract class BaseActivity extends Activity {

	protected Application application;
	public SharedPreferences sp;
	protected FragmentManager fm;
	protected FragmentTransaction  transaction;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	   
	    application = getApplication();
		sp = getSharedPreferences("STU_DATA", MODE_PRIVATE);
	}
	/**
	 * 切换fragment
	 * @param frag
	 */
	protected void changeFragment(int containerViewId,Fragment frag){
    	fm = getFragmentManager();
		//FragmentTransaction执行碎片操作，添加替换，删除
		transaction= fm.beginTransaction();
		transaction.replace(containerViewId, frag);
		transaction.commit();
    }
}
