Regarding finding the behavior of a hard key with a progress bar (android)

When the progress dialog box is displayed and we press the search key, it closes and moves to the phone’s search bar, even if the Dialog setcancellable value is set to false.

How can we avoid this?

+3
source share
3 answers

It works for me

dialog = new ProgressDialog(this){
    @Override
    public boolean onSearchRequested() {
        return false;
    }
};
+1
source

. . , . , , . , , .

0

I had the same problem, and I fixed it by setting OnKeyListenera progress dialog that uses the search button:

    dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
                return true;
            } else {
                return false;
            }
        }
    });

It helps me.

0
source

Source: https://habr.com/ru/post/1756930/


All Articles