활동:
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Fragment1 fragment = new Fragment1();
Fragment2 fragment2 = new Fragment2();
transaction.replace(R.id.Fragment1, fragment);
transaction.addToBackStack(null);
transaction.commit();
FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
transaction2.replace(R.id.Fragment1, fragment2);
transaction2.addToBackStack(null);
transaction2.commit();
보기의 코드 :
<fragment
android:id="@+id/Fragment1"
android:name="com.landa.fragment.Fragment1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_below="@+id/include1" />
문제는 콘텐츠가 실제로 교체되지 않는다는 것입니다.
다시 클릭하면 첫 번째 조각이 제대로 표시되지만 (두 번째 조각은 제외) 처음에는 둘 다 표시됩니다 (마지막 조각 만 표시하고 싶습니다).
내가 여기서 무엇을 놓치고 있습니까?
containerViewId합니다 (의replace방법).