Android sleep() without blocking UI

前端 未结 4 1451
无人及你
无人及你 2020-12-14 07:44

For my new Android application I need a function, that timeout my application for 3 Seconds. I tried the function \"sleep()\" like this:

seekBar1.setProgress         


        
4条回答
  •  余生分开走
    2020-12-14 08:21

    You can use postDelayed() method like this:

    handler=new Handler();
    Runnable r=new Runnable() {
        public void run() {
            //what ever you do here will be done after 3 seconds delay.              
        }
    };
    handler.postDelayed(r, 3000);
    

提交回复
热议问题