Can i Create the object of a activity in other class?

前端 未结 3 726
悲哀的现实
悲哀的现实 2020-11-22 09:34

i have defined a function in mainactivity now i want to access with another class in my app.I have created a object of the mainactivity by using that object i have called th

3条回答
  •  长情又很酷
    2020-11-22 10:15

    Make the variable public and then create object in adapter like this:

    public int i;  // Variable in Activity class
    
    ((ActivityName) context).i          // accessing in adapter 
    

提交回复
热议问题