Android SDK override AlertDialog events
I am instantiating an alert dialog like so:
AlertDialog myAlert = new AlertDialog.Builder(myContext).create();
Is the开发者_如何转开发re a way to override the OnKeyDown
event for this dialog?
AlertDialog.Builder build=new AlertDialog.Builder(this);
build.setMessage("This is a message, dawg.")
.setPositiveButton("Awesomesauce.", new OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
//stuff here
dialog.dismiss(); //closes the window
}
};
AlertDialog myAlert=build.create();
myAlert.show();
You can also add a .setNegativeButton()
or .setNeutralButton()
to change the neutral/negative buttons, too.
The Android SDK doc for it is here.
精彩评论