1. Are you ready for the Galaxy S20? Here is everything we know so far!

The code does not work in the Thread by pressing a button

Discussion in 'Android Devices' started by mcpixel, Jul 13, 2019.

  1. mcpixel

    mcpixel Newbie
    Thread Starter

    I'm studying android and stumbled upon a problem! After reading this article in the section Worker Threads: https://developer.android.com/guide/components/processes-and-threads.html
    My code
    Code (Java):
    1. public void click(View view) {
    2.         new Thread(new Runnable() {
    3.             @Override
    4.             public void run() {
    5.                 final TextView t = findViewById(R.id.textView);
    6.                 t.setText("Wait...");
    7.                 for(int i=0;i<999999;i++)
    8.                     Log.e("test", ""+System.currentTimeMillis());
    9.                 t.post(new Runnable() {
    10.                     @Override
    11.                     public void run() {
    12.                         t.setText("Complete");
    13.                     }
    14.                 });
    15.             }
    16.         });
    17.     }
    Now when I press a button, nothing happens even the text does not change and there are no mistakes. I don’t know what to do, help somebody!

Alcatel Zip Forum

Features and specs are not yet known.

Release Date

Share This Page