Unable to access variable from innerclass : Kotlin android

后端 未结 3 645
离开以前
离开以前 2021-01-03 18:06

I am new to Kotlin development in android. here I am trying to access a variable defined in a class from it\'s inner class as below.

class MainActivity : Ap         


        
3条回答
  •  执念已碎
    2021-01-03 18:50

    to answer this question for the fast an easy way i would do something like following :

    class OuterClass{
    
    private var accessibleInside: CustomObject? = null
    inner class InnerClass{
    
        //....
    }
    

    now the CustomObject could be anything from Context to String hope this helps someone.

提交回复
热议问题