📜  片段到片段 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:31.848000             🧑  作者: Mango

代码示例1
public void onClick2(View view) {
    Fragment2 fragment2 = new Fragment2();
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.fragment1, fragment2);
    fragmentTransaction.commit();
}