安卓开发怎么通过点击按钮弹出以下窗口?
1个回答
展开全部
你可以获取对话框的点击事件,比如点击了确定然后你就跳转
AlertDialog.Builder builder = new Builder(CommentActivity.this);
builder.setMessage("确定要跳转吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
arg0.dismiss();
这里跳转到你想要去的页面
}
});
builder.setNegativeButton("取消",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
arg0就是该listener的接口啊,通过这个参数就可以关闭对话框。
跳到想去的页面就startIntent就好了,你把那一行中文换成 Intent it = new Intent(this,UserActivity.class); startActivity(it); 当然要跳去哪个页面就你自己决定
AlertDialog.Builder builder = new Builder(CommentActivity.this);
builder.setMessage("确定要跳转吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
arg0.dismiss();
Intent it = new Intent(this,UserActivity.class);
startActivity(it);
}
});
builder.setNegativeButton("取消",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
AlertDialog.Builder builder = new Builder(CommentActivity.this);
builder.setMessage("确定要跳转吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
arg0.dismiss();
这里跳转到你想要去的页面
}
});
builder.setNegativeButton("取消",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
arg0就是该listener的接口啊,通过这个参数就可以关闭对话框。
跳到想去的页面就startIntent就好了,你把那一行中文换成 Intent it = new Intent(this,UserActivity.class); startActivity(it); 当然要跳去哪个页面就你自己决定
AlertDialog.Builder builder = new Builder(CommentActivity.this);
builder.setMessage("确定要跳转吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
arg0.dismiss();
Intent it = new Intent(this,UserActivity.class);
startActivity(it);
}
});
builder.setNegativeButton("取消",
new android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询