Display Android dialog on top of another?

后端 未结 4 965
离开以前
离开以前 2020-12-19 07:46

I have 2 alert dialogs, dialog A and dialog B. Clicking on one of dialog A\'s buttons will bring up dialog B. I then want to have a button that will dismiss dialog B and ret

4条回答
  •  离开以前
    2020-12-19 08:37

    You should use inside your custom layout one view/button and based on this view/button click you can create another dailog without cancel first one, if you use builder.setNegativeButton or builder.setPositiveButton your current dialog will be close, my working code like as,

    AlertDialog.Builder builder = new AlertDialog.Builder(ActivityAppImages.this,R.style.your_style);
    LayoutInflater inflater = getLayoutInflater();    
    View dialoglayout = inflater.inflate(R.layout.your_custom_layout, null);
    
    final Button mButtonCreateOtherDailog = (Button)dialoglayout.findViewById(R.id.txt_create_second_dailog);
        mTextView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //create your other dailog here
            }
        });
    
    builder.setView(dialoglayout);
    builder.show();
    

提交回复
热议问题