I create a simple quiz app with 4 options. The application works as follows: The user answers the question (presses one of the four buttons (options)), the next question appears, etc. It so happens that you have to do without a click handler to display the next question. I would like to make a small pause with a length of 1-2 seconds before showing the next question, that is, after the user's response, so that he sees and remembers the correct answer. How can you make such a pause (delay)? Is it possible to set a time limit?
1 answer
You need to create a handler, put a call to your method inside and start the handler with a delay specified in milliseconds.
like that:
Handler handler = new Handler(); Runnable runnable = new Runnable() { @Override public void run() { //тут вызов вашего метода doSomething(); } }; handler.postDelayed(runnable, 1500); //в данном случае, стоит 1.5 секунды |