开发者

Android Menu not working

开发者 https://www.devze.com 2023-04-11 13:12 出处:网络
I have the following activity... package org.dewsworld; import android.app.Activity; import android.os.Bundle;

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

Android Menu not working

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:

  1. Are you sure main_menu.xml put in correct directory?
  2. Did you save your XML and source code file (*.java)?
  3. After changing XML content, did you clean the project properly?
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号