Reputation: 9
i m using a alert dialog box in my application,when alert dialog box appears my whole activity goes to background and a black appears.i want that when dialog box appears then my activity looks as it is as it looks before,i don't wan any background scenario?
Upvotes: 0
Views: 2330
Reputation: 1
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();
}
});
Upvotes: 0
Reputation: 7295
You need to use transparent flag for your dialog. But probably you gonna need to create your custom dialog for it:
Dialog mDialog = new Dialog(mContext, android.R.style.Theme_Translucent);
Custom dialog: android dialog transparent
AlertBox: Set Transparent Window in AlertDialog box
Upvotes: 4
Reputation:
Try this:
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(); } }
Upvotes: 2