java - alternative to findViewById() in classes other than activities (Android Studios) -


i'm working on android game have several levels , since each level have same code, thought idea create code in separate class , using object of class use code. however, of current code inside main activity uses findviewbyid() refer different view in app i'm unfortunately unable use function outside of activity inside normal class file. there alternative ways of referring views may able use in other classes?

thanks

you have several options so, maybe can pass view parameter careful check if view in correct context , if view exists in current screen avoid null pointer exceptions. it's difficult decide if solution can work without seeing code


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -