android AlertDialog用作底部弹出菜单

来源:互联网 发布:法律英语软件 编辑:程序博客网 时间:2024/05/14 04:00
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setItems(mItems, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// 点击后弹出窗口选择了第几项
if (which == 0) {
Intent intent = new Intent(SquareActivity.this, PublishSquare.class);
startActivityForResult(intent, 9);
} else if (which == 1) {
Intent intent = new Intent(SquareActivity.this,
PublishSquareVideoActivity.class);
startActivityForResult(intent, 1);
}
else {
return;
}


}
});
AlertDialog dialog = builder.create();
Window window = dialog.getWindow();
window.setGravity(Gravity.BOTTOM); // 此处可以设置dialog显示的位置
window.setWindowAnimations(R.style.mystyle); // 添加动画
dialog.show();
0 0