I have a menu and would like to open a new Activity when the user clicks on the menu item:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.add_symbol:
System.out.println("ADD SYMBOL CLICKED!");
Intent myIntent = new Intent(this.getContext(), AddStocksActivity.class);
startActivityForResult(myIntent, 0);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
I'm not sure how to create my Intent properly
Compiler Error:
The method getContext() is undefined for the type Main