안드로이드 자바 코틀린 기초 지식/안드로이드 예제 및 코드 (3) 썸네일형 리스트형 MVVM pattern MVVM 예제 1. fragment_mvvm_pattern.xml 2. MainViewModel.class import androidx.lifecycle.ViewModel class MainViewModel : ViewModel() { private var num = 0 fun getTotal(): Int{ return num } fun addNum(input : Int){ num += input } } 3. MvvmPatternFragment.fragment import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.databin.. MVP 패턴 MVP 패턴 기본 내용 : https://growing-software-engineer.tistory.com/25 예제 코드 : 1. Contract.interface interface Contract { interface View { fun showProgress() fun hideProgress() fun setString(string: String?) } interface Model { interface OnFinishedListener { fun onFinished(string: String?) } fun getNextCourse(onFinishedListener: OnFinishedListener?) fun initCourse(onFinishedListener: OnFinishedListener.. MVC 패턴 MVC 관련 내용: https://growing-software-engineer.tistory.com/25 예제 추가 : 1. MvcModel class import java.util.* class MvcModel : Observable() { val List: MutableList init { List = ArrayList(3) List.add(0) List.add(0) List.add(0) } //Getter Setter 메소드 @Throws(IndexOutOfBoundsException::class) fun getValueAtIndex(the_index: Int): Int { return List[the_index] } @Throws(java.lang.IndexOutOfBoundsException:.. 이전 1 다음