Last active
December 7, 2020 16:45
-
-
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/
This file contains hidden or 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
// 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