final Button OptButton = (Button) findViewById(R.id.OptButton);
OptButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent OptionsSc = new Intent(this, OptionsActivity.class);
startActivity (OptionsSc);
}
});
Eclipse keeps underlining the new Intent(this, OptionsActivity.class); part and I don’t get why. Previously this call to the OptionsActivity was assigned to the hardware Search button and everything worked fine.
In your case
thisdoesn’t refer to a validContext(like when you usethisin anActivity), instead it refers to the anonymous inner classOnCLickListenerclass(where is theonClickmethod declare). Instead you should use: