How to Prevent an Alert Dialog Getting Closed by Back Button

后端 未结 3 2067
一个人的身影
一个人的身影 2021-02-12 19:19

I have an alert dialog like this:

    AlertDialog.Builder oyunaBaslaDialog = new AlertDialog.Builder(this);
    oyunaBaslaDialog.setMessage(\"A Takımı\");
    oy         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-02-12 20:04

    Implement setOnKeyListener and catch the KeyEvent.KEYCODE_BACK. If you return true in this method, dialog will not close.

提交回复
热议问题