Skip to content

Instantly share code, notes, and snippets.

@ivangarzab
Created September 7, 2022 01:36
Show Gist options
  • Save ivangarzab/a6857dee689d33ddb760ee93dd2400dd to your computer and use it in GitHub Desktop.
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
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