Wait for 5 seconds

前端 未结 8 1890
借酒劲吻你
借酒劲吻你 2021-02-01 04:00

I want to wait 5 seconds before starting another public void method. The thread sleep was not working for me. If there is a way of wait() without using Threads I wo

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-01 04:39

    See if this works for you. Be sure to import the android.os.Handler

          Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    public void run() {
                        // yourMethod();
                    }
                }, 5000);   //5 seconds
    

提交回复
热议问题