'메뉴'에 해당되는 글 1건

  1. 2011.05.19 Android - Create Option
posted by Full-stack Developer 2011. 5. 19. 13:58
@Override
 public boolean onCreateOptionsMenu(Menu menu)
 {
  menu.add(0, 1, 0, "Update").setIcon(R.drawable.update);
  return super.onCreateOptionsMenu(menu);
 }
 
 @Override
 public boolean onOptionsItemSelected(MenuItem item)
 {
  switch ( item.getItemId() ) {
  case 1:
   InitContents();
   Toast.makeText(ctx, "Update Success.", Toast.LENGTH_SHORT);
   return true;
  }
  return false;
 }

-----------------------------------------------------

menu.add(0, 1, 0, "Update").setIcon(R.drawable.update);
Parameters
groupId The group identifier that this item should be part of. This can be used to define groups of items for batch state changes. Normally use NONE if an item should not be in a group.
itemId Unique item ID. Use NONE if you do not need a unique ID.
order The order for the item. Use NONE if you do not care about the order. See getOrder().
title The text to display for the item.