Activity
val bundle = Bundle()
bundle.putString("isEdited", "true")
// set Fragmentclass Arguments
// set Fragmentclass Arguments
val fragobj = Fragment()
fragobj.setArguments(bundle)
Fragment
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val isEdited = requireArguments().getString("isEdited")
return inflater.inflate(R.layout.fragment_more, container, false)
}
1. 프래그먼트에서 액티비티 함수 호출
to call activity function from fragment
(activity as MainActivity).loginCheck(ScheduleFragment())
((MainActivity)getActivity()).testFunction();
2. 액티비티에서 프래그먼트 함수 호출
Fragment function call from Activity
'Android > Kotlin' 카테고리의 다른 글
갱신 갱신 갱ㅇ신!!!!!!! (0) | 2021.08.02 |
---|---|
map 코드 받아서 보면서 알게 된 것들 (0) | 2021.07.31 |
Maven 설치할 때 오류 (0) | 2021.07.28 |
Fragment에서 뒤로가기 버튼 클릭시 프래그먼트 종료 (0) | 2021.07.25 |
Uri.Parse / 전화걸기, 이메일 넘어가기, 웹페이지 넘어가기 등 (0) | 2021.07.25 |