Data binding interfaces with implementations for Android Java and Kotlin. No code generation. You can easily extend it but your own!
- visibility
- enabled
- click
- text
- items
- progress (int)
- nav button click
Gradle is the only supported build configuration.
Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
implementation "com.github.codeerow.databinding:core:2.0.1-beta"
implementation "com.github.codeerow.databinding:androidx-core:2.0.1-beta" // androidx-core-ktx for Kotlin
implementation "com.github.codeerow.databinding:androidx-recyclerview:2.0.1-beta" // androidx-recyclerview-ktx for Kotlin
}
ViewModel:
val name = MutableLiveData<String>()
val email = MutableLiveData<String>()
val title = MutableLiveData<String>()
val description = MutableLiveData<String>()
LifecycleOwner (e.g. Fragment):
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
dataBinding {
with(inputName) {
text(viewModel.name, twoWay = true)
}
with(inputEmail) {
text(viewModel.email, twoWay = true)
}
with(inputTitle) {
text(viewModel.title, twoWay = true)
}
with(inputDescription) {
text(viewModel.description, twoWay = true)
}
}
}