Android: Accessing UI Element from timer thread

后端 未结 3 671
庸人自扰
庸人自扰 2020-12-01 14:05
public Button stb;
static int cnt=0;
public ArrayList Butgrp1 = new ArrayList();
Timer myt; 
TimerTask t;
stb.setOnClickListene         


        
3条回答
  •  鱼传尺愫
    2020-12-01 14:49

    You can pass the Activity as a parameter to the method that runs the timertask, and then you can use Activity.runOnUiThread to execute your tasks in UI Thread. There are lots of post in stackoverflow site regarding the usage of runOnUiThread usage.

提交回复
热议问题