
1. Interface를 이용하는 방법 2. ViewModel을 공유하는 방법 1. Interface를 이용하는 방법 fragment_red.xml fragment_green.xml activity_main.xml FragmentRed.kt package com.jwsoft.kotlinproject import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import kotlinx.android.synthetic.main.fragment..

1. onAttach()에서 Context 파라미터를 이용하여 Activity 객체를 생성하는 방법 2. Bundle 객체를 생성해서 Fragment의 전달인자로 보내는 방법 3. ViewModel을 공유하는 방법 1. onAttach()에서 Context 파라미터로 Activity 객체 생성하여 전달받는 방법 activity_main.xml fragment_red.xml fragment_green.xml FragmentGreen.kt package com.jwsoft.kotlinproject import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View imp..
Activity, Service, Broadcast Receiver, Content Provider Intent를 통해서 호출된다. - Activity 1. Activity 클래스를 상속받아 사용 2. 사용하려면 manifest에 선언해야 함 3. UI 화면을 담당하는 컴포넌트 - Service 1. Service 클래스를 상속받아 사용 2. Background에서 실행되는 컴포넌트 3. 화면이 존재하지 않음 4. manifest에 선언해야 함 5. 네트워크 작업을 통해서 데이터를 가져올 수 있음 예) 배경음악 - Broadcast Receiver 1. BroadcastReceiver 클래스를 상속받아 사용 2. 디바이스에서 발생하는 일 중에서 애플리케이션이 알아야 하는 상황이 발생하면 알려줌 예) 배터..

소스 : Activity와 Fragment 간의 ViewModel 공유 처음 앱을 실행하면 Activity가 생성된 후에 Fragment가 생성된다. 화면 회전 시 위처럼 생명주기가 진행된다. 두 번째 페이지로 이동했을 때의 생명주기 다시 회전하면 위와 같은 생명주기를 거친다. onPause() 되어있던 FragmentRed도 생명주기를 거쳐 다시 onStart()로 돌아온다. 잠시 후 FragmentRed가 onResume() 상태가 안되면 완전히 파괴된다. FragmentGreen는 현재 화면이므로 파괴되지 않는다. FragmentGreen은 onPause() 상태가 되고 파괴됐던 FragmentRed는 재생성된다. Fragment Count 가 0이 된 이유는 FragmentRed가 재생성 됐기 때..

build.gradle (Module: app) android { dataBinding { enabled = true } kotlinOptions { jvmTarget = "1.8" // viewModels() 사용 } } dependencies { // viewModels() 사용 implementation 'androidx.fragment:fragment-ktx:1.2.5' // ViewPager2 사용 implementation 'androidx.viewpager2:viewpager2:1.0.0' } activity_main.xml fragment_red.xml fragment_green.xml fragment_blue.xml fragment_white.xml fragment_black.xml Ma..
- Total
- Today
- Yesterday
- DataBinding
- James Kim
- XML
- fragment
- Kotlin
- recyclerview
- ViewModel
- Intent
- Vue.js #Vue.js + javascript
- activity
- 코틀린
- CoordinatorLayout
- 안드로이드
- Android
- 자바
- 혀가 길지 않은 개발자
- ViewPager2
- JSONObject
- TabLayout
- handler
- ArrayList
- MVVM
- 안드로이드 #코틀린 #Android #Kotlin
- java
- Design Pattern
- View
- JSONArray
- Architecture Pattern
- Livedata
- coroutine
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |