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?
3 Answers
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
7 Comments
user1227605
R.style.Theme_Translucent_NoTitleBar_Fullscreen is not working with my custom dialog box....
user1227605
public CustomizeDialog(Context context) { super(context); mContext = context; /** 'Window.FEATURE_NO_TITLE' - Used to hide the mTitle / requestWindowFeature(android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); // requestWindowFeature(Window.FEATURE_NO_TITLE); /* Design the dialog in main.xml file */ setContentView(R.layout.customdialog); v = getWindow().getDecorView(); v.setBackgroundResource(android.R.color.transparent);
user1227605
when my dialog is appear then background colour of my activity is being low,looks like little bit black,what i want is when dialog is in foreground then there is no change in background activity
user1227605
public class CustomizeDialog extends Dialog implements OnClickListener { @Override public void onWindowAttributesChanged(LayoutParams params) { super.onWindowAttributesChanged(params);} ContextmContext; public CustomizeDialog(Context context) { super(context); mContext =context;requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.customdialog); v = getWindow().getDecorView(); v.setBackgroundResource(android.R.color.transparent);}
goodm
try: super(context, android.R.style.Theme_Translucent);
|
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(); } } Comments
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(); } });