A library that makes Android View Binding usage easier.
It supports extensions for:
- Activity
- Fragment (DialogFragment e.t.c)
- ViewHolder
- Create binding in your Activity/Fragment/ViewHolder
private val binding by viewBinding(MainFragmentBinding::bind)
* MainFragmentBinding is the generated binding class for your 'main_fragment.xml' layout file
- Use it to interact with views
binding.titleText.isVisible = true
binding.someButton.setOnClickListener { ... }
- Enable ViewBinding in build.gradle of your project/module:
android {
//...//
buildFeatures {
viewBinding true
}
//...//
}
- Add it in your settings.gradle:
dependencyResolutionManagement {
//..//
repositories {
//..//
maven { url 'https://jitpack.io' }
//..//
}
}
- Add the dependency in build.gradle of your project/module:
dependencies {
//..//
implementation 'com.github.dragote:view-binding-delegate:1.0'
//..//
}