0

In Android Studio

Simply adding the following code to MainActivity.Java causes the error. @override is also underlined red and there is an issue with "onClick(View view)" where the second view is red?

ImageButton ib1 = (ImageButton) findViewById(R.id.imageButton);

ib1.setOnClickListener(new View.OnClickListener() {

    @Override
           public void onClick(View view) {
        Intent intent = new Intent(this, dexter.class);
        startActivity(intent);
    }
});
Malakan
  • 43
  • 1
  • 1
  • 6

1 Answers1

0

The syntax is

ib1.setOnClickListener(new OnClickListener(){
...
}

no View. in front of the listener.

Akunosh
  • 237
  • 1
  • 2
  • 10