2024-01-01から1年間の記事一覧

Recycler View

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Add Recycler View Create a new project and drag a recycler view component to activity_main.xml, give it id name "recyclerView". 2. Create a Layout for List Item Name it l…

Pass Data Between Fragments

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. First, check my previous note Then in HomeFragment, do: val bundle = bundleOf("user_name" to binding.editTextText.text.toString()) it.findNavController().navigate(R.id.actio…

Enum Class書き方

enum class Trend { INCREASING, DECREASING, PEAK }

Use Data Binding In Fragment

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Check my previous note: Simple Data Binding Step 1 and 2 are the same. In step3, we need to write it in a different way. Before: class BlankFragment : Fragment() { override …

Navigation Between Fragments

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Add Dependencies Reference In project layer's build.gradle.kts: buildscript { ... dependencies { val nav_version = "2.7.7" classpath("androidx.navigation:navigation-safe-…

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" } } }

現在のthreadはmain threadかのチェック

Thread.isMainThread