为什么在android中Menu不显示??
packagecom.etc;importandroid.app.Activity;importandroid.content.Intent;importandroid....
package com.etc;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
public class MenuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
public boolean onOptionItem(MenuItem item){
int item_id=item.getItemId();
switch (item_id) {
case R.id.about:
Intent intent=new Intent();
intent.setClass(MenuActivity.this, Next.class);
startActivity(intent);
break;
case R.id.exit:
MenuActivity.this.finish();
break;
default:
break;
}
return true;
}
} 展开
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
public class MenuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
public boolean onOptionItem(MenuItem item){
int item_id=item.getItemId();
switch (item_id) {
case R.id.about:
Intent intent=new Intent();
intent.setClass(MenuActivity.this, Next.class);
startActivity(intent);
break;
case R.id.exit:
MenuActivity.this.finish();
break;
default:
break;
}
return true;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询