これを行うには複数の方法があります。私はフラグメントを使用することを好みます。
/**
* Adding given Fragment into content area without transition.
* This is good for initializing view.
* @param f
*/
private void addContentView(Fragment f){
FragmentTransaction ft =getSupportFragmentManager().beginTransaction();
ft.add(R.id.contentPane, f).commit();
}
/**
* Replacing Fragment in content area with given Fragment
* @param f Fragment to display
* @param tag String of the content area
* @param animIn Resource ID for new screen transition.
* @param animOut Resource ID for old screen transition.
*/
private void replaceContentView(Fragment f, String tag, int animIn, int animOut){
// -1 is passed when I want to use default animation.
if(animIn == -1) animIn = R.anim.fragment_slide_left_enter;
if(animOut == -1) animOut = R.anim.fragment_slide_left_exit;
FragmentTransaction ft =getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(animIn, animOut); // Animate new view in and existing view out
ft.replace(R.id.contentPane, f, tag); // id of the FrameLayout to put the Fragment in
ft.commit();
}