dialogplus icon indicating copy to clipboard operation
dialogplus copied to clipboard

Nested dialogs?

Open DarkionAvey opened this issue 10 years ago • 6 comments

I was messing around with DialogPlus, and I came accoss this "issue". I'm not able to show a child dialog from parent dialog. Here's the code:

        final ArrayAdapter<String> childAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new String[]{"Nothing to do", "do nothing"});

    final DialogPlus child = DialogPlus.newDialog(Settings.this)
            .setInAnimation(R.anim.dialogin).setBackgroundColorResourceId(R.color.bg)
            .setOutAnimation(R.anim.dialogout)
            .setAdapter(childAdapter)
            .create();


    final ArrayAdapter<String> parentAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new String[]{"Dismiss", "Show another dialog"});

    final DialogPlus parent = DialogPlus.newDialog(Settings.this)
            .setInAnimation(R.anim.dialogin).setBackgroundColorResourceId(R.color.bg)
            .setOutAnimation(R.anim.dialogout)
            .setAdapter(parentAdapter)
            .setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
                    switch (position) {
                        case 0:
                            dialog.dismiss();

                            break;

                        case 1:
                            child.show();
                            dialog.dismiss();

                            break;

                    }
                    Log.v("Issue", parentAdapter.getItem(position));


                }
            })
            .create();

    parent.show();

Logcat report of clicks: 08-16 02:56:16.702 28131-28131/net.darkion.test V/Issue﹕ Dismiss 08-16 02:56:20.980 28131-28131/net.darkion.test V/Issue﹕ Show another dialog

However, the second dialog is shown when child.show(); is added an OnDismissListener()

DarkionAvey avatar Aug 15 '15 19:08 DarkionAvey

Sorry for late reply, I'm currently in vacation, I'll check this issue very soon.

orhanobut avatar Aug 21 '15 12:08 orhanobut

Hi, i run into same problem. Debugging shows that both dialogs run into the show method correctly. Even if i do not dismiss the first dialog the second is not shown.

supremedk1 avatar Sep 01 '15 08:09 supremedk1

Also have this issue :)

broakenmedia avatar Dec 14 '15 13:12 broakenmedia

Did any one solve the issue? Its 2016 and still I am facing same.

sanjogshrestha avatar Aug 03 '16 07:08 sanjogshrestha

Trick, use delay for waiting last dialog dismissed

My code in Kotlin

menuLogout.setOnClickListener {
    dialog.dismiss()
    Handler().postDelayed({
        // Your dialog here
    }, 600)
}

menuLogout is list item inside first dialog dialog is first dialog

ProyekRiad avatar Apr 25 '18 14:04 ProyekRiad

Did any one solve the issue? with postDelayed it's working but, I need a solution without tricks thank you 👍 @ProyekRiad @orhanobut

sehli avatar Jan 07 '21 18:01 sehli