开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜