Created
September 7, 2022 01:36
-
-
Save ivangarzab/a6857dee689d33ddb760ee93dd2400dd to your computer and use it in GitHub Desktop.
Example on how to create a "custom object" in Android using Data Binding + Kotlin Extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun ExampleViewBinding.bind( | |
resources: Resources, | |
onAction: (Any) -> Unit | |
) { | |
this.title = resources.getString(R.string.title) | |
this.setSaveClickListener { | |
this.subtitle = when (someData) { | |
true -> R.string.subtitle1 | |
false -> R.string.subtitle2 | |
} | |
this.setButtonClickListener { | |
onAction(it) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment