我目前在我的应用程序中有一个大问题。 我在整个应用程序中使用Theme.Light。结果非常好,但我注意到在ICS中,Dialog有白色背景,而在以前的版本中,背景是黑色的(请参见下面的屏幕截图)什么是最好的做法来设置我的CustomDialog的主题扩展Dialog实现OnClickListener
我的第一个想法是对项目和使用布局-v14与黑暗的文本和布局文件夹与白色文本。
,这将是工作,但我真的想设置对话框的主题,就像我与经典对话做:
return new AlertDialog.Builder(AlertDialogSamples.this, AlertDialog.THEME_TRADITIONAL)
.create();
现在的问题是我的自定义对话框扩展对话框,我没有更多的
public class MyCustomDialog extends Dialog implements OnClickListener {
int THEME=AlertDialog.THEME_TRADITIONAL;
public MyCustomDialog(Activity plannerActivity) {
super(plannerActivity);
View myView=//Something;
setContentView(myView);
}
}
,并在我的主要代码:可能性与建筑商玩
new MyCustomDialog(getActivity()).show();
由于我无法访问构建器,因此无法更改我的CustomDialog的主题,并且完全陷在我的应用程序中。
非常感谢您的帮助!
编辑添加的更多信息
诚如通过维内特舒克拉,我尝试新的DialogYour(Activity.this,android.R.style.Theme_Translucent_NoTitleBar),但构造DialogYour(活动,int)未定义。
我无法用主题覆盖DialogYour,因为有些东西是android内部的!
当我看着对话框代码:
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);
}
我不能重写,因为PolicyManager属于com.android.internal
的问题是,构造DialogYour(活动,INT)是不确定的!你如何在你的例子中定义DialogYour? – 2011-12-27 10:36:58
通过这一行:Dialog dialog = new DialogYour(Activity.this,android.R.style.Theme_Translucent_NoTitleBar); – 2011-12-27 10:38:09
是的,但DialogYour(Activity,int)未定义!你的线路无法工作。等2分钟,将在第一篇文章中添加代码,并且由于我必须设置很多点击侦听器,我不能使用默认对话框,我需要创建一个新类:MyCustomDialog extends Dialog – 2011-12-27 10:51:54