메뉴 만들기 및 클릭 이벤트 처리

1494 단어 android관련되다
    ,                id     ,               ,       ,   
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	// TODO Auto-generated method stub
    	menu.add(0, 1, 0, "append");
    	menu.add(0, 2, 1, "item2");
    	menu.add(0, 3, 2, "clear");
    	//It`s important to return true to see the menu.
    	return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	// TODO Auto-generated method stub
    	//           
    	
    	Log.i(TAG, item.getItemId()+ ""	);
    	return super.onOptionsItemSelected(item);
    }
 @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	// TODO Auto-generated method stub
    	//           
    	Log.i(TAG, item.getItemId()+ ""	);
    	item.setOnMenuItemClickListener(new MyResponse());
    	return super.onOptionsItemSelected(item);
    }
    class MyResponse implements OnMenuItemClickListener{

		@Override
		public boolean onMenuItemClick(MenuItem item) {
			// TODO Auto-generated method stub
			Log.i(TAG, "MyResponse +++++++++" + item.getIntent().getAction());
			return false;
		}
 

좋은 웹페이지 즐겨찾기