I'm currently trying to create a basic action bar in my app. I'm trying to override the onCreateOptionsMenu method in my Main Activity but am getting an error that "method does not override or implement a method from a supertype". However, I see in the 'Activity' class definition (https://developer.android.com/reference/android/app/Activity.html) that it does contain the method. So, please help me understand why i'm not able to override the method?
Here's the MainActivity class code along with all the imports:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean OnCreateOptionsMenu(Menu menu)
{
//Inflate the menu. this adds items to the action bar if it is present
getMenuInflater().inflate(R.menu.menu_main,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch(item.getItemId())
{
case R.id.action_create_order:
//Code to run when the create order item is clicked
Intent intent=new Intent(this,OrderActivity.class);
startActivity(intent);
return true;
case R.id.action_settings:
//Code to run when the settings item is clicked
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}