調(diào)用Android fragment框架的步驟如下:
public class MyFragment extends Fragment {
// ...
}
FragmentManager fragmentManager = getSupportFragmentManager();
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
MyFragment myFragment = new MyFragment();
fragmentTransaction.add(R.id.fragment_container, myFragment);
fragmentTransaction.commit();
通過(guò)以上步驟,就可以在Android中調(diào)用fragment框架來(lái)管理和顯示fragment的內(nèi)容。