MaterialDesignLibrary icon indicating copy to clipboard operation
MaterialDesignLibrary copied to clipboard

Dialog closing twice

Open MelodyAustin opened this issue 10 years ago • 9 comments

I had set the dialog for a menu option click, when I press the close button it acts like it is closing twice. I have just copied your code for test.

public void settings_click(MenuItem item) {

    Dialog dialog = new Dialog(MainActivity.this, "Title", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam");
    dialog.setOnAcceptButtonClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MainActivity.this, "Click accept button", Toast.LENGTH_LONG).show();
        }
    });
    dialog.setOnCancelButtonClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MainActivity.this, "Click cancel button",Toast.LENGTH_LONG).show();
        }
    });
    dialog.show();
}

the setting menu is randomly generated by android studio on creation, I have just added onClick to it.

When I press the accept or cancel button, there is a really bad closing. It acts like closing twice or something, the activity jumps when the dialog closes..

Is there anything else that I must do to make it smooth?

MelodyAustin avatar Jan 19 '15 15:01 MelodyAustin

I have the same problem as @MelodyAustin. I'm on Android 4.2.2. The behavior is just like MelodyAststin described: it's like the dialog is closing (disappearing), then coming back very quickly, and then finally closing for real. I downloaded the latest version of the demo apk file, and the dialog behaves the same way there. I have not seen this problem in emulators running android 4.4.2 (have not tried any other emulator).

I hope you can find the source of this bug. I really like your library!

jonahe avatar Feb 03 '15 00:02 jonahe

I also came across this!

tankilo avatar Feb 03 '15 13:02 tankilo

Same here!

Drakot avatar Feb 09 '15 19:02 Drakot

That behavior can't be reproduced testing in an emulator with Nexus 4 with Android 2.3.7, but in a real device such as Samsung Galaxy S3 with Android 4.2.2 it happens.

filipebezerra avatar Feb 28 '15 03:02 filipebezerra

Same problem on Android 4.2.1 and Android 4.2.2 On Android 4.4.4 works well. Has anyone found a solution?

beprogressive avatar Mar 02 '15 01:03 beprogressive

I had to add another library for dialogs

https://github.com/afollestad/material-dialogs

Drakot avatar Mar 15 '15 13:03 Drakot

I had the same problem. I hope you find this bug. I really like your library.

JuanAlejandro avatar Apr 09 '15 14:04 JuanAlejandro

Me too, I'm using three different libraries, for Snackbars, Dialogs and Floating Actions in accordance with Material Design spec:

  • https://github.com/afollestad/material-dialogs
  • https://github.com/nispok/snackbar
  • https://github.com/str4d/android-floating-action-button

filipebezerra avatar Apr 09 '15 18:04 filipebezerra

Hi, i work also in this library, but unfortunately we don't have any device with these characteristics. If anyone who has any of these devices and can solve the problem, please let us know and we will include the solution on a new version.

xcelder avatar Nov 07 '16 21:11 xcelder