Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. class MyGenericCustomView<T>(context: Context, attrs: AttributeSet) : AnotherView(context, attrs) {
  2. ...
  3. }
  4.  
  5. <package.name.MyGenericCustomView
  6. android:id="@+id/custom_id"
  7. ....
  8. />
  9.  
  10. override fun onCreate(...) {
  11. ...
  12. val myCustomView = findViewById<MyGenericCustomView<String>>(R.id.custom_id)
  13. ...
  14. }
  15.  
  16. //custom_id is of type MyGenericCustomView<*>
  17.  
  18. class MySpecificCustomView(context: Context, attrs: AttributeSet) : MyGenericCustomView<String>(context, attrs) {
  19. ....
  20. }
  21.  
  22. val myView = custom_id as MyGenericCustomView<String>
  23.  
  24. class MyActivity() : Activity(…) {
  25.  
  26. val myView by lazy { custom_id as MyGenericCustomView<String> }
  27.  
  28. ...
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement