1
다른 하나의 조각을 가지고 succussfuly를 추가하고 커밋합니다. 그러나 제거하고 싶을 때 작동하지 않으며 항상 그 위치입니다.다른 하나의 자식 조각을 제거 할 수 없습니다
주요 활동 조각
public class MainActivityFragment extends Fragment {
ScreenUtility screenUtility;
public MainActivityFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_main, container, false);
screenUtility = new ScreenUtility(getActivity());
TotalAmountFragment totalAmountFragment;
totalAmountFragment = new TotalAmountFragment();
if (screenUtility.getOrientation() == 1){
getChildFragmentManager()
.beginTransaction()
.add(R.id.main_total_amount_fragment_container, totalAmountFragment, "totalPrice")
.commit();
} else if (screenUtility.getOrientation() == 2 && getChildFragmentManager().findFragmentByTag("totalPrice") != null){
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
transaction.remove(totalAmountFragment);
transaction.commit();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
}
return v;
}
}
XML 파일
...
<FrameLayout
android:id="@+id/main_total_amount_fragment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foregroundGravity="center"
android:layout_centerHorizontal="true"/>
어떻게해야합니까? 내가 생각했던대로 했어.
가 작동하지 않음이 코드를보십시오! 태블릿이 처음 시작할 때 풍경이되면 조각이 추가되지 않고 세로로 회전하면 하위 조각이 올바르게 표시되지만 가로로 다시 회전하면 제거되지 않습니다! – altruistic
조각을 바로 바꾸지 않는 이유는 무엇입니까? – Madhav
무엇으로 교체 하시겠습니까? – altruistic