ViewModel as a variable in XML

This page summarizes the projects mentioned and recommended in the original post on /r/androiddev

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • architecture-samples

    A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.

  • I'm studying "Android App Development with Kotlin" by Google at Udacity. In one of the lessons, you are taught how to handle clicking items from a RecyclerView in the fragment, using a callback function, like this: val clickListener: (sleepId: Long) -> Unit) , and from the fragment calling any methods of your ViewModel. Studying this project https://github.com/android/architecture-samples, the pattern used to handle clicks is to send the ViewModel to the ViewHolder and add it to the binding as a variable and make all the XML method calls, like this: android: onClick = "@{viewModel.taskComplete(task)}".Performatively, which of these ways is faster?

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts