Android Menu not working
I have the following activity...
package org.dewsworld;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
public class MenuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
s开发者_如何学JAVAetContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater() ;
inflater.inflate(R.menu.main_menu, menu) ;
return true;
}
}
ad my main_menu.xml is
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/item1" android:title="Home"></item>
<item android:id="@+id/item2" android:title="Client List"></item>
<item android:id="@+id/item3" android:title="Amar matha"></item>
<item android:id="@+id/item4" android:title="Tomar matha"></item>
</menu>
And my logcat report is
Please help...Build and clean your project first...
If the problem persist check the Resource Id #0x7f050000 in packagename.R.id.NAME_String
You would get the name of Resource value that is creating problem... Delete all it;s references create newer and then clean and run the project...
In precise way... Try to use Debud Perspectives to solve your minor faults
With Regards,
Arpit
Some question beforehand:
- Are you sure
main_menu.xml
put in correct directory? - Did you save your XML and source code file (*.java)?
- After changing XML content, did you clean the project properly?
精彩评论