Hello, my name is Yosuke. I used "==" to match strings (laughs). It's equals!
The method that blinks this character is the one that was implemented when the app was first published. Calculator with calculation problem ← As the name suggests, this app is an app with a function to give a calculation problem to the calculator. It has become. When the calculation problem starts, the timer starts, and when all 10 questions are cleared, the timer stops and blinks at that time. Also, when you finish answering, the past clear time is displayed.
It's a childish code because it doesn't matter if it's too long, but I'll post it as a memorandum of my own.
Quest.java
public class Quest extends AppCompatActivity {
private final Handler handler = new Handler();
//Show timer
private TextView timerText;
...Omission...
//If you answer all the questions correctly, timer_stop()Call
//Timer stop
public void timer_stop() {
handler.removeCallbacks(runnable);
timerText.setTextColor(Color.RED);
count = 0;
insert_db();
result_tweet();
init();
}
//Method to make the stopped time flickering
private void init() {
new Thread(new Runnable() {
@Override
public void run() {
int time = 500;
try {
Thread.sleep(time);
} catch (Exception e) {
}
handler.post(new Runnable() {
@Override
public void run() {
if (timerText.getVisibility() == View.VISIBLE) {
timerText.setVisibility(View.INVISIBLE);
} else {
timerText.setVisibility(View.VISIBLE);
}
init();
}
});
}
}).start();
}
}
The timer stopped by this init () method is blinking. Since I made a program referring to this → How to blink the text view, I can only understand the general flow, and also Thread and handler. I regret that I haven't studied enough because I haven't studied enough. (Method name ...)
Currently, we are developing the third app, "One Day Diary (Fukuoka Edition)" (tentative title). I will write it when I arrive at a paragraph or when I want to post it, so thank you (^ ^). By the way, I also do Twitter, so please feel free to follow me! → Twitter account
Reference URL: How to make the text view blink: https://codeday.me/jp/qa/20190108/126818.html
Recommended Posts