2019独角兽企业重金招聘Python工程师标准>>>
package org.crazyit.menu;import org.crazyit.menu.R;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;/*** Description:*
site: crazyit.org *
Copyright (C), 2001-2012, Yeeku.H.Lee*
This program is protected by copyright laws.*
Program Name:*
Date:* @author Yeeku.H.Lee kongyeeku@163.com* @version 1.0*/
public class ActivityMenu extends Activity
{@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);}@Overridepublic boolean onCreateOptionsMenu(Menu menu){// -------------向menu中添加子菜单-------------SubMenu prog = menu.addSubMenu("启动程序");// 设置菜单的图标prog.setIcon(R.drawable.tools);// 设置菜单头的图标prog.setHeaderIcon(R.drawable.tools);// 设置菜单头的标题prog.setHeaderTitle("选择您要启动的程序"); // 添加菜单项MenuItem item = prog.add("查看经典Java EE");//为菜单项设置关联的Activityitem.setIntent(new Intent(this , OtherActivity.class));return super.onCreateOptionsMenu(menu);}
}
/*** */
package org.crazyit.menu;import org.crazyit.menu.R;import android.app.Activity;
import android.os.Bundle;/*** Description:*
网站: 疯狂Java联盟 *
Copyright (C), 2001-2012, Yeeku.H.Lee*
This program is protected by copyright laws.*
Program Name:*
Date:* @author Yeeku.H.Lee kongyeeku@163.com* @version 1.0*/
public class OtherActivity extends Activity
{@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);//设置该Activity显示的页面setContentView(R.layout.other); }
}