프라그먼트2 Android] Fragment 생성시에는 newInstance로. All subclasses of Fragment must include a public no-argument constructor. The framework will often re-instantiate a fragment class when needed, in particular during state restore, and needs to be able to find this constructor to instantiate it. If the no-argument constructor is not available, a runtime exception will occur in some cases during state restore. 화면회전이나 화면 재생성으로 인해 Fragment 재생성시 no-a.. 2025. 1. 24. Android] 다른 액티비티에서 프라그먼트 교체 / 뷰페이저 A프라그먼트에서 a액티비티로 화면 전환 후, a액티비티 화면에서 back 버튼으로 갔을 때 이전과 다른 B프라그먼트가 나오도록 하는 코드. #뷰페이저 두 프라그먼트는 같은 액티비티 안에 있어야 합니다. A 액티비티내 프라그먼트에서 B 액티비티로 이동 val intent = Intent(activity, B::class.java) activity?.startActivityForResult(intent, 12345) B 액티비티에서 setResult 설정 setResult(Activity.RESULT_OK) 프라그먼트를 가진 액티비티의 뷰페이저 currentItem 변경. #onActivityResult if (requestCode == 12345) { if (RESULT_OK == resultCode) {.. 2021. 4. 29. 이전 1 다음