I wanted to make a program that would quickly read the text from 0 to a huge number. As I just did not try to do it - it does not work. The first option was without displaying the number on the screen and without Thread.Sleep and it worked, but still everything went smoothly and transparently.
public void button2(View view) throws InterruptedException { TextView textbody1 = (TextView)findViewById(R.id.textView4); //почему-то activity крашится, если прописать эту строку там же, где и переменные do { count ++; //переменные типа int объявлены в шапке класса countlast = count+5; textbody1.setText("Число равно:"+count); Thread.currentThread().sleep(150);} while (count < countlast); I tried both with smaller numbers and without an infinite loop - the result is the same: the program hangs on both the emulator and the iron device.
Yes, I understand that I’ve gotten pretty nasty somewhere, but I’m just learning, and unfortunately I can only learn in practice, otherwise I won’t remember anything.
It seems to be hanging down and updating the textview, but it hangs when the button is pressed, and I can’t understand anything about the Android Studio logs, except that it eats too many resources. Surely there is some less perverted way to perform this simple task.