ondrovic
Newbie
So I wanted to add menu options to the app I am working on. I did a sample app to make sure that I had the logic down and everything worked great. When I added the menu to the real app all I am getting is the menu no other layout.
Here is the code
Here is my main_menu.xml
Did I screw up when adding the code to make the menu? I just don't understand why I can get it working in a sample 1 class app but not in this one.
Thanks for the help
Here is the code
Code:
package com.bestbuymobile;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
public class Main extends Activity {
public static String debug = "DEBUG";
public static boolean dFlag; ///Debug flag, true=enabled, flase=disabled
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
if(Main.dFlag) {
Log.d(Main.debug, "onCreate Event");
Log.d(Main.debug, "Checking dFlag state");
}
dMsgs();
}
public void dMsgs() {
Main.dFlag = false;
}
/*
public void onStart() {
super.onStart();
if(Main.dFlag) {
Log.d(Main.debug, "onStart Event");
}
//System.runFinalizersOnExit(true);
//System.exit(0);
}
public void onResume() {
super.onResume();
if(Main.dFlag) {
Log.d(Main.debug, "onResume Event");
}
//System.runFinalizersOnExit(true);
//System.exit(0);
}
public void onRestart() {
super.onRestart();
if(Main.dFlag) {
Log.d(Main.debug, "onRestart Event");
}
//System.runFinalizersOnExit(true);
//System.exit(0);
}
public void onPause() {
super.onPause();
if(Main.dFlag) {
Log.d(Main.debug, "onPause Event");
}
//System.runFinalizersOnExit(true);
//System.exit(0);
}
public void onStop() {
super.onStart();
if(Main.dFlag) {
Log.d(Main.debug, "onStop Event");
}
//System.runFinalizersOnExit(true);
//System.exit(0);
}
public void onDestroy() {
super.onDestroy();
if(Main.dFlag) {
Log.d(Main.debug, "onDestroy: Exiting Application");
}
System.runFinalizersOnExit(true);
System.exit(0);
}
*/
public void single_clicked(View view) {
if(Main.dFlag) {
Log.d(Main.debug, "Single Plan Button Clicked");
}
startActivity(new Intent(getApplicationContext(), Single.class));
}
public void multi_clicked(View view) {
if(Main.dFlag) {
Log.d(Main.debug, "Multi Plan Button Clicked");
}
startActivity(new Intent(getApplicationContext(), Multi.class));
}
public void data_clicked(View view) {
if(Main.dFlag) {
Log.d(Main.debug, "Data Plans Button Clicked");
}
startActivity(new Intent(getApplicationContext(), Data.class));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.layout.main_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.feedback:
return true;
case R.id.about:
return true;
}
return false;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
return true;
}
}
Code:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/feedback"
android:title="Sumbit Feedback" />
<item
android:id="@+id/about"
android:title="Program Info" />
</menu>
Did I screw up when adding the code to make the menu? I just don't understand why I can get it working in a sample 1 class app but not in this one.
Thanks for the help