Friday, March 27, 2015

Android : Why am I not allowed to use setOnClickListener in this situation?



This makes no sense, I am given an error saying that setOnClickListener can't be applied to MainActivity. But i've made other projects where I've never encountered this problem. What's going on?



public class MainActivity extends ActionBarActivity {

Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


button = ((Button) findViewById(R.id.button));

button.setOnClickListener(this);

}

No comments:

Post a Comment