I want to open a new activity when i click on an imageview.
MainActivity:
public void menu (View view) {
Intent i = new Intent(this, Menu.class);
startActivity(i);
}
Menu:
public class Menu extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
}
}
When I run the app and i click on the imageview the app crashes and gives the error:
java.lang.IllegalStateException: Could not execute method for android:onClick
As these answeres suggest:
Creating new activity, Intent error
P.S I changed my code but it still gave the same error.this seems like a very stupid mistake of mine.Can anyone help me to find my mistake? Thanks in advance!