I am currently having a big issue in my application.
I use the Theme.Light in my whole application. The result is great, but I noticed that in ICS, the Dialog have white background, and in previous versions, the background was black (see screenshot below)
My first idea was to use different layout for the items and use layout-v14 with dark text and layout folder with white text.
That will be working but I really would like to set the theme of the Dialog like I do with classic dialog:
return new AlertDialog.Builder(AlertDialogSamples.this, AlertDialog.THEME_TRADITIONAL)
.create();
The problem is now that my custom Dialog extends Dialog and I have no more the possibility to play with the builder:
public class MyCustomDialog extends Dialog implements OnClickListener {
int THEME=AlertDialog.THEME_TRADITIONAL;
public MyCustomDialog(Activity plannerActivity) {
super(plannerActivity);
View myView=//Something;
setContentView(myView);
}
}
and in my main code:
new MyCustomDialog(getActivity()).show();
As I have no more access to the builder, I cannot change the Theme of my CustomDialog and I am completely stuck in my app.
Thank a lot for any help!

EDIT TO ADD MORE INFO
As advised by Vineet Shukla, I tried new DialogYour(Activity.this, android.R.style.Theme_Translucent_NoTitleBar), but the constructor DialogYour(Activity, int) is undefined.
I cannot override the DialogYour with a theme, as some stuff are internal to android!
When I look into the Dialog Code:
Dialog(Context context, int theme, boolean createContextWrapper) {
if (theme == 0) {
TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(com.android.internal.R.attr.dialogTheme,
outValue, true);
theme = outValue.resourceId;
}
mContext = createContextWrapper ? new ContextThemeWrapper(context, theme) : context;
mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
Window w = PolicyManager.makeNewWindow(mContext);
mWindow = w;
w.setCallback(this);
w.setWindowManager(mWindowManager, null, null);
w.setGravity(Gravity.CENTER);
mUiThread = Thread.currentThread();
mListenersHandler = new ListenersHandler(this);
}
I cannot override, because PolicyManager belong to com.android.internal
I have tried
custom dialogbut not this way. I haveoverriddentheonCreateDialogin theactivitylike this with themeandroid.R.style.Theme_Translucent_NoTitleBarYou can try this way and you will achieve your desired layout for custom layout.
Note: You can also try with the theme
android.R.style.Theme_Translucent_NoTitleBarin your code.Edit1:
I have not tried but To set the theme in your case you can try like this:
Edit2: I have tested your code and the issue was in your
constructor.now call the above dialog like this: