Android ViewModelFactory 사용하기

사용 버전: Android Studio 4.0

사용 언어: Kotlin 1.3.72

안드로이드 ViewModelFactory 사용하기에 대해서 알아보겠습니다.

ViewModelFactory는 ViewModel을 생성할 때, 전달되는 인자가 있으면 사용합니다.

먼저 ViewModel을 사용해야 합니다.

링크 참조.

https://shwoghk14.blogspot.com/2020/06/android-viewmodel.html










Factory를 적용할 ViewModel입니다.


New - Kotlin File/Class를 누릅니다.


ViewModelFactory를 만듭니다.

       


ViewModel과 같은 변수명을 적습니다.


create 함수를 override 합니다.


원래 Fragment 파일로 돌아옵니다.

viewModel과 viewModelFactory를 만듭니다.


끝.



카테고리: Android






[계수기] 앱 광고

외국: Hand Counter




계수기 앱.

하나씩 개수를 셀 때 사용해보세요.

센 숫자를 메모와 함께 저장할 수 있습니다.


감사합니다.


[계수기] 앱 광고 끝.


댓글

이 블로그의 인기 게시물

Python OpenCV 빈 화면 만들기

Python urllib.parse.quote()

Python bytes.fromhex()

Android AVD Ram size change

Forensics .pyc 파일 .py로 복구하기

Android Minimum touch target size

KiCad 시작하기 7 (FreeRoute 사용하기 2)

Android Notification with Full Screen

C++ OpenCV 모폴로지 침식, 팽창

KiCad 시작하기 2 (PCB 만들기)