How set a 'timer' before running body from if/else statement?
How set a 'timer' before running body from if/else statement?
In android studio, I want to set some kind of 'timer' before the if/else
statement runs parts of it's body. In this case the edit1.setText("")
and edit1.setBackgroundColor(Color.parseColor("#FFFFFFF"));
Is there a way to do this.
if/else
edit1.setText("")
edit1.setBackgroundColor(Color.parseColor("#FFFFFFF"));
Thanks in advance, have a nice day!
EDIT: I'm not using any UI libraries.
public void check1(View view)
uinput = edit1.getText().toString();
if (uinput.equals(answerList[0]))
edit1.setBackgroundColor(Color.parseColor("#00FF00"));
score++;
score_view.setText(String.valueOf(score));
// I only want to delay the three below.
view1.setText(questionList[1]);
edit1.setText("");
edit1.setBackgroundColor(Color.parseColor("#FFFFFF"));
else
edit1.setBackgroundColor(Color.parseColor("#FF0000"));
wrong++;
wrong_view.setText(String.valueOf(wrong));
// I only want to delay the three below.
view1.setText(questionList[1]);
edit1.setText("");
edit1.setBackgroundColor(Color.parseColor("#FFFFFFF"));
You say you're not using any UI libraries, but you're using methods and classes that suggests you're using Swing. Is that not the case?
– Carcigenicate
Sep 1 at 18:52
If I understand right I need to declare a library? If so I'm not using swing or anything else.
– Jane Doe
Sep 1 at 18:57
What is
View
from?– Carcigenicate
Sep 1 at 18:59
View
view is a
TextView
. And the View in the method is from onClick
.– Jane Doe
Sep 1 at 19:00
TextView
onClick
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
If this is Swing, you'll probably want to use Swing Timers to execute this.
– Carcigenicate
Sep 1 at 18:26