// Reference to "name" TextView using synthetic properties.name.text=viewModel.nameString// Reference to "name" TextView using the binding class instance.binding.name.text=viewModel.nameString
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Migrate from Kotlin synthetics to Jetpack view binding\n\nKotlin Android Extensions is deprecated, which means that using Kotlin\nsynthetics for view binding is no longer supported. If your app uses Kotlin\nsynthetics for view binding, use this guide to migrate to Jetpack view binding.\n\nIf your app doesn't already use Kotlin synthetics for view binding, see [View\nbinding](/topic/libraries/view-binding) for basic usage information.\n\nUpdate the Gradle file\n----------------------\n\nLike Android Extensions, Jetpack view binding is enabled on a module-by-module\nbasis. For each module that uses view binding, set the `viewBinding` build\noption to `true` in the module-level `build.gradle` file: \n\n### Groovy\n\n```groovy\nandroid {\n ...\n buildFeatures {\n viewBinding true\n }\n}\n```\n\n### Kotlin\n\n```kotlin\nandroid {\n ...\n buildFeatures {\n viewBinding = true\n }\n}\n```\n\nIf your app doesn't use [`Parcelable`](/reference/android/os/Parcelable)\nfeatures, remove the line that enables Kotlin Android Extensions: \n\n### Groovy\n\n```groovy\nplugins {\n id 'kotlin-android-extensions'\n}\n```\n\n### Kotlin\n\n```kotlin\nplugins {\n kotlin(\"android.extensions\")\n}\n```\n| **Note:** If your app uses `Parcelable` features, switch to using the standalone `kotlin-parcelize` Gradle plugin described in [Parcelable implementation generator](/kotlin/parcelize).\n\nTo learn more about enabling view binding in a module, see [Setup\ninstructions](/topic/libraries/view-binding#setup).\n\nUpdate activity and fragment classes\n------------------------------------\n\nWith Jetpack view binding, a binding class is generated for each XML layout file\nthat the module contains. The name of this binding class is the name of the XML\nfile in Pascal case with the word *Binding* added at the end. For example, if\nthe name of the layout file is `result_profile.xml`, the name of the generated\nbinding class is `ResultProfileBinding`.\n\nTo use the generated binding classes instead of synthetic properties to\nreference views, change your activity and fragment classes by doing the\nfollowing:\n\n1. Remove all imports from `kotlinx.android.synthetic`.\n\n2. Inflate an instance of the generated binding class for the activity or\n fragment to use.\n\n - For activities, follow the instructions in [Use view binding in\n activities](/topic/libraries/view-binding#activities) to inflate an instance in your activity's [`onCreate()`](/reference/kotlin/android/app/Activity#oncreate) method.\n - For fragments, follow the instructions in [Use view binding in\n fragments](/topic/libraries/view-binding#fragments) to inflate an instance in your fragment's [`onCreateView()`](/reference/kotlin/androidx/fragment/app/Fragment#oncreateview) method.\n3. Change all view references to use the binding class instance instead of\n synthetic properties:\n\n // Reference to \"name\" TextView using synthetic properties.\n name.text = viewModel.nameString\n\n // Reference to \"name\" TextView using the binding class instance.\n binding.name.text = viewModel.nameString\n\nTo learn more, see the [Usage](/topic/libraries/view-binding#usage) section in\nthe view binding guide.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [View binding](/topic/libraries/view-binding)\n- [Paging library overview](/topic/libraries/architecture/paging/v3-overview)\n- [Test your Paging implementation](/topic/libraries/architecture/paging/test)"]]