I'm glad to have a method to blink characters on Android

Hello, my name is Yosuke. I used "==" to match strings (laughs). It's equals!

Implemented with the first app I made

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.

Source code

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

I'm glad to have a method to blink characters on Android
I tried adding a separator line to TabLayout on Android
How to create a method
Why do I have to do a "method"? ~ "Main only" would have worked ~
A memorandum on how to use Eclipse
How to redo a deployment on Heroku
Sample to display (head-up) notifications on Android
How to detect microphone conflicts on Android
How to have params in link_to method
Android Easily give a "press" to a button
I made a calculator app on Android
I have a question about Android studio.
Find a value that is convenient to have a method and make it a ValueObject