java.lang.IllegalStateException: commit already called

배롱·2022년 12월 7일
0

FragmentManager를 만들어 모든 Fragment를 만져주는 기능을 만들려했다
replace를 해준 뒤 commit을 하는 로직인데 에러가 발생했다


FATAL EXCEPTION: main
    Process: com.b3lon9.warming, PID: 19817
    java.lang.IllegalStateException: commit already called
fragmentTransaction.replace(container, fragment).commit();

FragmentTransaction 객체를 새로 생성해주어 해결

FragmentTransaction fragmentTransaction = ((MainActivity)mContext).getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(container, fragment).commit();

0개의 댓글