Skip to content
Advertisement

I tried using a handler, but it said ‘cannot resolve symbol”Handler”‘

What do i do to be able to use a handler to update my TextView every 2 secs because right now it comes up with ‘cannot resolve symbol”Handler”‘

int noStart = 20;
int minus = 5;

public void number(View view) {
    final TextView tx = (TextView) findViewById(R.id.number);

    if(noStart<0){
        new Handler().postDelayed(new Runnable() {
            public void run() {
                noStart -= minus;
                tx.setText(String.valueOf(noStart));
            }
        }, 2000);
    }
}

Advertisement

Answer

Check your activity imports and add this line to the class:

import android.os.*

Advertisement