Using Fragment Kotlin Extensions in Java Class Libraries: Best Practices
groovy
apply plugin: 'kotlin-android'
groovy
dependencies {
implementation 'androidx.fragment:fragment-ktx:1.2.5'
}
kotlin
class MyFragment : Fragment() {
}
kotlin
import kotlinx.android.synthetic.main.fragment_my.*
class MyFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
textView.text = "Hello, World!"
button.setOnClickListener {
}
}
}