[안드로이드,Android]메뉴 옵션
2013. 1. 24. 09:40ㆍMobile/Android
반응형
package com.example.ggari_optionmenu; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.SubMenu; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("아래 쪽 메뉴를 눌러봐요(까리)"); setContentView(tv); } public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0,1,0,"메뉴A"); //int groupId, int itemId, int order, CharSequence title menu.add(0,2,0,"메뉴B"); SubMenu etc = menu.addSubMenu("etc"); etc.add(0,3,0,"etc A"); etc.add(0,4,0,"etc B"); return true; } public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 1: Toast.makeText(this,"메뉴A~~~~",1).show(); return true; case 2: Toast.makeText(this,"메뉴B~~~~~",1).show(); return true; case 3: Toast.makeText(this,"etc A~~~~~~~~~",1).show(); return true; case 4: Toast.makeText(this,"etc B ~~~~~",1).show(); return true; } return false; } }
반응형
'Mobile > Android' 카테고리의 다른 글
[안드로이드,Android]키보드 보이기, 숨기기 (0) | 2013.01.28 |
---|---|
[안드로이드,Android]로그,LOG (0) | 2013.01.25 |
[안드로이드,Android]타이머 Timer (0) | 2013.01.23 |
[안드로이드,Android] RatingBar (별점수) (2) | 2013.01.21 |
[안드로이드,Android]탭,TabHost 만들기 (0) | 2013.01.15 |