Skip to content

Instantly share code, notes, and snippets.

@aztack
Created January 22, 2012 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aztack/1655848 to your computer and use it in GitHub Desktop.
Save aztack/1655848 to your computer and use it in GitHub Desktop.
3 button alert dialog
Dialog dialog = new AlertDialog.Builder(this).setIcon(
android.R.drawable.btn_star).setTitle("喜好调查").setMessage(
"你喜欢李连杰的电影吗?").setPositiveButton("很喜欢",
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(Main.this, "我很喜欢他的电影。",
Toast.LENGTH_LONG).show();
}
}).setNegativeButton("不喜欢", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(Main.this, "我不喜欢他的电影。", Toast.LENGTH_LONG)
.show();
}
}).setNeutralButton("一般", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(Main.this, "谈不上喜欢不喜欢。", Toast.LENGTH_LONG)
.show();
}
}).create();
dialog.show();
@aztack
Copy link
Author

aztack commented Jan 22, 2012

创建一个有3个按钮、自定义icon的对话框

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment