On Tuesday, June 21, 2016 at 9:27:20 PM UTC+5:30, Guruprasad Srinivasamurthy wrote: > > Hi All, > 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);* > > * }* > > * }* > > > > *}* > > > > Thanks, > Guru > > Hi Buddy check this useful article
https://www.mindstick.com/Articles/1520/adding-the-action-bars-and-action-buttons-in-andriod http://hmkcode.com/android-menu-handling-click-events-changing-menu-items-at-runtime/ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/65fc8e60-b45b-4d26-b3bc-ef4d4f8d3cc4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

