直接上代码吧!
public class AlertDialogUsage extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
new AlertDialog.Builder(AlertDialogUsage.this)
.setTitle("Powe level")
.setMessage("Griffin's AlertDialog sample!")
.setPositiveButton("Yes",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialoginterface, int i)
{
Log.d("TAG","[setPositiveButton]");
}
}
)
.setNegativeButton("No", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialoginterface, int i)
{
Log.d("TAG","[setNegativeButton]");
}
}
)
.show();
}
}