Skip to content

Instantly share code, notes, and snippets.

@ch8n
Last active December 7, 2020 16:45
Show Gist options
  • Save ch8n/ce375e5e47d3108e98be5c9e46cac342 to your computer and use it in GitHub Desktop.
Save ch8n/ce375e5e47d3108e98be5c9e46cac342 to your computer and use it in GitHub Desktop.
sample fragment using base fragment 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 fragment class
class ProfileFragment :ViewBindingFragment<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