一、OptionsMenu的创建

 

	private final int MENU_ABOUT = Menu.FIRST;
	private final int MENU_EXIT = Menu.FIRST + 1;
	public boolean onCreateOptionsMenu(Menu menu){
		String menuLabels[] = {"关于" , "退出"};
		for( int order = 0 ; order < menuLabels.length ; order++ ){
			menu.add( 0 , Menu.FIRST + order , order, menuLabels[order] );
		}
		return super.onCreateOptionsMenu(menu);
	}

	public boolean onOptionsItemSelected(MenuItem item){
		super.onOptionsItemSelected(item);
		switch(item.getItemId()){
		case MENU_ABOUT:toast(item.getTitle() + "");break;
		case MENU_EXIT:toast(item.getTitle() + "");break;
		}
		return false;
	}
	public void toast(String str) {
		Toast.makeText(Main.this,str,Toast.LENGTH_LONG).show();
	}

Menu功能菜单 

相关文章:

  • 2021-07-29
  • 2021-07-26
  • 2022-12-23
  • 2021-07-01
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-14
  • 2021-12-20
  • 2021-11-29
  • 2021-06-30
  • 2021-11-21
  • 2021-08-28
  • 2021-08-25
相关资源
相似解决方案