Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyGenericCustomView<T>(context: Context, attrs: AttributeSet) : AnotherView(context, attrs) {
- ...
- }
- <package.name.MyGenericCustomView
- android:id="@+id/custom_id"
- ....
- />
- override fun onCreate(...) {
- ...
- val myCustomView = findViewById<MyGenericCustomView<String>>(R.id.custom_id)
- ...
- }
- //custom_id is of type MyGenericCustomView<*>
- class MySpecificCustomView(context: Context, attrs: AttributeSet) : MyGenericCustomView<String>(context, attrs) {
- ....
- }
- val myView = custom_id as MyGenericCustomView<String>
- class MyActivity() : Activity(…) {
- val myView by lazy { custom_id as MyGenericCustomView<String> }
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement