android.os.Handler handler = new android.os.Handler(); private Runnable runnable = new Runnable() { @Override public void run() { mainActivity.clearUI();//主线程中,更新UI handler.postDelayed(runnable, 300);//300ms调用此方法 } }; public void start() { stop(); handler.post(runnable); } private void stop() { handler.removeCallbacks(runnable);//移除回调 }
Android 定时异步刷新UI
最新推荐文章于 2022-04-19 15:58:13 发布