How to have generic ViewModel in BaseActivty class
问题 I want to have a base activity class that takes care of some initialization I started defining it like this. abstract class BaseActivity<VIEW_MODEL : ViewModel, BINDING : ViewDataBinding> : AppCompatActivity() { lateinit var viewmodel: VIEW_MODEL lateinit var binding: BINDING lateinit var glide: RequestManager @get:LayoutRes abstract val layoutResource: Int override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this,