Changing ui from thread

前端 未结 2 470
孤独总比滥情好
孤独总比滥情好 2021-01-26 04:51

I know there were similiar question, but my problem slightly different i have such code

 Thread t = new Thread(){
        public void run(){
            while(!r         


        
相关标签:
2条回答
  • 2021-01-26 05:02

    You can use this activity method:

    YourActivity.this.runOnUiThread(new Runnable() {
      @Override
      public void run(){ 
          //Your awesome code here
    
      }
    });
    
    0 讨论(0)
  • 2021-01-26 05:20

    well in the change now you can do

    new Handler(Looper.getMainLooper()).post(new Runnable() {
    
        @Override
        public void run() {
        // your ui code here
    
        }
    });
    
    0 讨论(0)
提交回复
热议问题