How to run a Runnable thread in Android at defined intervals?

后端 未结 11 1968
青春惊慌失措
青春惊慌失措 2020-11-22 02:50

I developed an application to display some text at defined intervals in the Android emulator screen. I am using the Handler class. Here is a snippet from my cod

11条回答
  •  广开言路
    2020-11-22 03:25

    Handler handler=new Handler();
    Runnable r = new Runnable(){
        public void run() {
            tv.append("Hello World");                       
            handler.postDelayed(r, 1000);
        }
    }; 
    handler.post(r);
    

提交回复
热议问题