Android创建Menu菜单实例
本文实例讲述了Android创建Menu菜单的方法。分享给大家供大家参考。具体方法如下:
package com.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
public class TestandroidActivity extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId())
{
case R.id.settings:
startActivity(new Intent(this,com.test.Settings.class));
return true;
}
return false;
}
}
以上是 Android创建Menu菜单实例 的全部内容, 来源链接: utcz.com/z/343080.html