0

i am learning how to use handlers, and i was following a tutorial and it has code as follows:

Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            TextView myTextView =
                    (TextView)findViewById(R.id.myTextView);
            myTextView.setText("Button Pressed");
        }
    };

the problem i am facing is, i am using android studio, and when i write:

Handler h = new Handler() {
..
..
}

it asks me to must implement these methods close(),flush(),publish().. and it never provide the method handleMessage() as requisite method to implement!!

please let me know how to fix it and to use handler properly

Amrmsmb
  • 1
  • 27
  • 104
  • 226

1 Answers1

1

Check your Handler class was imported is:

import android.os.Handler;
Tran Vinh Quang
  • 585
  • 2
  • 9
  • 30