phoenix13

导航

 

1. add a fragment to a view

FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.add(R.id.fragment_container, mFriendsFragment);
ft.addToBackStack(null);// this is optional, use this if you want to come back to the old fragment
ft.commit();

main activity view

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

 

posted on 2014-11-08 11:00  phoenix13  阅读(163)  评论(2编辑  收藏  举报