October 2019
Intermediate to advanced
434 pages
11h 54m
English
Let's now explore the Fragment KTX module, which contains utility functions for working with fragments. First, we'll define our new dependency constant:
object Android { ... object Ktx { const val core = "androidx.core:core-ktx:1.0.1" const val fragment = "androidx.fragment:fragment-ktx:1.0.0" }}
Now, we'll update app/build.gradle.kts:
dependencies { ... implementation(Deps.Android.Ktx.core) implementation(Deps.Android.Ktx.fragment)}
Once the dependency is added, we can define FragmentTransactions using the commit() extension function like this:
supportFragmentManager.commit { addToBackStack("fragment name") add(SampleFragment(), "tag") setCustomAnimations(R.anim.abc_fade_in, R.anim.abc_fade_out)}
This makes the addition ...
Read now
Unlock full access