• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

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

mcpixel

Newbie
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
Java:
public void click(View view) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                final TextView t = findViewById(R.id.textView);
                t.setText("Wait...");
                for(int i=0;i<999999;i++)
                    Log.e("test", ""+System.currentTimeMillis());
                t.post(new Runnable() {
                    @Override
                    public void run() {
                        t.setText("Complete");
                    }
                });
            }
        });
    }
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!
 
Back
Top Bottom