2024-03-01から1ヶ月間の記事一覧

2 Way Binding between ViewModel and xml Components

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Enable xml to Access to ViewModel see this note 2. Edit ViewModel class MainActivityViewModel: ViewModel() { val userName = MutableLiveData("Frank") } 3. In xml, When Dis…

Using LiveData ViewModel in xml

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Set up Data Binding See this note 2. Set up ViewModel See this note 3. Edit ViewModel class MainActivityViewModel: ViewModel() { private val _count = MutableLiveData(0) v…

LiveData (Which is similar to ObservableObject in SwiftUI)

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Create ViewModel Please check the previous note. 2. Edit ViewModel class MainActivityViewModel: ViewModel() { private val _count = MutableLiveData(0) val count: LiveData<Int> </int>…

ViewModel

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Add Dependencies In app/build.gradle, add the following dependencies: dependencies { def lifecycle_version = "2.7.0" implementation "androidx.lifecycle:lifecycle-viewmode…

Pass object from Activity to xml

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Set up Data Binding Please see my previous note. 2. Edit the xml File <layout ...> <data> <variable name="student" type="com.xxx.xxx.Student" /> </data> <androidx.constraintlayout.widget.ConstraintLayout ...> ... </androidx.constraintlayout.widget.constraintlayout></layout>

Simple Data Binding

1. In app/build.gradle, add the following code: android { ... dataBinding { enabled = true } } Also it can be android { ... buildFeatures { dataBinding = true } } 2. Add an extra layout in layout xml file. Before: <androidx.constraintlayout.widget.ConstraintLayout xmlns:... android:...> ... </androidx.constraintlayout.widget.constraintlayout>

カスとマイズerrorのlocalizedDescription

enum CustomizedError: LocalizedError { case unexpectedError case sessionNotExist var errorDescription: String? { switch self { case .unexpectedError: return "unexpected error" case .sessionNotExist: return "session not exist" } } }