Android Extensions for Views
The previous use is rather restrictive, because there are many other parts of the code where we could
need to access the views inside an XML. For example, a custom view or an adapter. For these cases,
there is an alternative which will bind the views of the XML to another view. The only difference is
the required
import
:
1
import kotlinx.android.synthetic.main.view_item.view.*
If we were in an adapter, for instance, we could now access the properties from the inflated views:
1
view.textView.text = "Hello"
Do'stlaringiz bilan baham: |