java - Create a dialogbox from another class with its own thread in Android -


this question has answer here:

i'm making little game in "gameview" "gamethread" inside it. extends view use constructor:

gameview(context context, attributeset attrs){ //initialization stuff } 

and add on main_activity.xml because controlled buttons. problem want make when game over, shows dialog score. don't know how this. 've tried creating reference context class attribute this:

gameview(context context, attributeset attrs){ this.context = context; } 

but can't call "runonuithread" this.

you can use ui thread's handler instead. instance using context , post runnable

 handler handler = new handler(looper.getmainlooper());             runnable myrunnable = new runnable() {                 @override                 public void run() {                     //do in ui thread                 }             };             handler.post(myrunnable); 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

android - MPAndroidChart - How to add Annotations or images to the chart -