android开发 - 菜单的使用

// 底部弹出菜单
@Override
public boolean onCreateOptionsMenu(Menu menu) {
this.getMenuInflater().inflate(R.menu.icon_photos_upload, menu);
return true;
}


// 底部菜单触发事件
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_people_takepictures:
// 拍照意图
Intent intent = new Intent(
android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, IMAGE_RESULT_CODE);
break;
case R.id.menu_people_selectionlibs:
// 选择图片库的图片
Intent intent2 = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent2, IMAGE_RESULT_OPEN_CODE);
break;
}
return true;
}

你可能感兴趣的:(android)