Warning dialog in android

im using the warning dialog in my application, when the warning dialog appears, all my activity goes to the background, and black appears. I want my activity to appear as it appears when the dialog box appears. There is no background script?

+1
source share
3 answers

You need to use a transparent flag for your dialog. But, probably, you will need to create your own dialogue for it:

Dialog mDialog = new Dialog(mContext, android.R.style.Theme_Translucent);

User dialogue: android transparent dialogue

AlertBox: Set a transparent window to the AlertDialog warning field

+4
source

Try the following:

 public class CustomDialog extends Dialog implements OnClickListener {      
  Button button_home,button_cancel,button_resume;     
    public GamePauseMenu(Context context) {          
      super(context,R.style.Theme_Transparent);      
      }     


    public void show(int bg) {              
             super.show();         
           setContentView(R.layout.custdialog);       
            button_resume = (Button)findViewById(R.id.imageButton1);                  button_resume.setOnClickListener(this);    
     }     public void onClick(View v) {         cancel();      }   } 
+2
 b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AlertDialog.Builder alertDialog2 = new AlertDialog.Builder(
                        MainActivity.this);

// Setting Dialog Title
                alertDialog2.setTitle("Confirm Delete...");

// Setting Dialog Message
                alertDialog2.setMessage("Are you sure you want delete this file?");

// Setting Icon to Dialog
               // alertDialog2.setIcon(R.drawable.delete);

// Setting Positive "Yes" Btn
                alertDialog2.setPositiveButton("YES",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                // Write your code here to execute after dialog
                                Toast.makeText(getApplicationContext(),
                                        "You clicked on YES", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        });

// Setting Negative "NO" Btn
                alertDialog2.setNegativeButton("NO",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                // Write your code here to execute after dialog
                                Toast.makeText(getApplicationContext(),
                                        "You clicked on NO", Toast.LENGTH_SHORT)
                                        .show();
                                dialog.cancel();
                            }
                        });

// Showing Alert Dialog
                alertDialog2.show();
            }
        });
0
source

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


All Articles