Skip to content

Instantly share code, notes, and snippets.

@ch8n
Created December 7, 2020 16:44
Show Gist options
  • Save ch8n/f49098072300454fddcb37ff7b9e74b1 to your computer and use it in GitHub Desktop.
Save ch8n/f49098072300454fddcb37ff7b9e74b1 to your computer and use it in GitHub Desktop.
sample for activity using base activity for view binding | checkout complete blog from - https://chetangupta.net/viewbinding/
// Source : https://chetangupta.net/viewbinding/
// file name : profile_layout.xml
<FrameLayout ... >
<TextView android:id="@+id/text_name" ... />
<TextView android:id="@+id/text_twitter" ... />
<TextView android:id="@+id/text_blog" ... />
</FrameLayout>
// controller activity class
class ProfileActivity :ViewBindingActivity<ProfileLayoutBinding>() {
override val bindingInflater: (LayoutInflater) -> ViewBinding
= ProfileLayoutBinding::inflate
override fun setup() = with(binding){
textAuthor = "chetan gupta"
textTwitter = "ch8n2"
textBlog = "chetangupta.net"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment