android dialog 的item项点击
//进入界面跳出的dialog样式
public void createDialog() {
builder = newAlertDialog.Builder(Index.this);
builder.setTitle(R.string._index_submenu_title);
builder.setItems(new String[] { "启动照相机", "打开手机相机", "取消选择" },
newDialogInte易做图ce.OnClickListener() {
@Override
public void onClick(DialogInte易做图cedialog, intwhich) {
// TODO Auto-generated method stub
//which为从0开始的。为使其也从1开始。
switch (which+1) {
case IMG_CAMERA:
OpenCamera();
break;
case IMG_FILE:
OpenFile();
break;
case SELECT_CANCEL:
break;
default:
break;
}
}
});
}
==========================================
dialo易做图击按钮的事件:
public void saveImageDialog(String path) {
ImageView newImage = new ImageView(Index.this);
Bitmap bitmap=MyCommon.fitSizeImg(path,1);
newImage.setImageBitmap(bitmap);
// 显示对话框
new AlertDialog.Builder(Index.this)
.setTitle("picture")
.setView(newImage)
.setPositiveButton("save",
new DialogInte易做图ce.OnClickListener() {
@Override
public void onClick(DialogInte易做图ce dialog,
int which) {
// TODO Auto-generated method stub
// 把图片路径保存到数据库中
imageDbhelp1.insertlujin(fileName);
finish();
Intent intent3 = new Intent(Index.this,
Index.class);
startActivity(intent3);
}
}).setNegativeButton("cancel", null).show();
}
作者:kankankankan2222
补充:移动开发 , Android ,