我在MainActivity.java中编写了以下代码,在android中创建了一个选项菜单:
package com.jain.ashutos;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.content.*;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.layout.menus, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.menu_about:
Toast.makeText(MenuSample.this, "You Clicked About",
3000).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
但是当我运行该程序时,我得到一个Error = Unknown Entity“MenuSample”。任何人都可以解决这个问题吗?