How to check “instanceof ” class in kotlin?

后端 未结 8 1575
有刺的猬
有刺的猬 2020-12-14 05:14

In kotlin class, I have method parameter as object (See kotlin doc here ) for class type T. As object I am passing different classes when I am calling metho

8条回答
  •  旧巷少年郎
    2020-12-14 05:56

    You can check like this

     private var mActivity : Activity? = null
    

    then

     override fun onAttach(context: Context?) {
        super.onAttach(context)
    
        if (context is MainActivity){
            mActivity = context
        }
    
    }
    

提交回复
热议问题