Java 标题未显示在对话框片段中
我有下面的样式来显示对话框的标题Java 标题未显示在对话框片段中,java,android,android-styles,Java,Android,Android Styles,我有下面的样式来显示对话框的标题 <style name="CustomDialog" parent="@style/Theme.AppCompat.Light.Dialog"> <item name="android:windowNoTitle">false</item> </style> 假的 但是,该对话框不显示标题。该对话框如下图所示。我还包含了用于初始化视图的代码 void initView(int maxLength) {
<style name="CustomDialog" parent="@style/Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">false</item>
</style>
假的
但是,该对话框不显示标题。该对话框如下图所示。我还包含了用于初始化视图的代码
void initView(int maxLength)
{
setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
getDialog().setTitle(title);
Window wnd = getDialog().getWindow();
if (wnd != null)
wnd.getAttributes().windowAnimations = R.style.dialog_animation;
Button dismiss = root.findViewById(R.id.numeric_done);
dismiss.setOnClickListener((View v) -> done());
this.maxLength = maxLength;
numericInputManager = new NumericInputManager(maxLength);
intStack = new Stack<>();
valueEnteredTV = root.findViewById(R.id.value_entered);
initButtons();
initRestrictions();
}
void initView(int-maxLength)
{
setStyle(DialogFragment.STYLE_NORMAL,R.STYLE.CustomDialog);
getDialog().setTitle(标题);
Window wnd=getDialog().getWindow();
如果(wnd!=null)
wnd.getAttributes().windowAnimations=R.style.dialog\u动画;
按钮解除=root.findviewbyd(R.id.numeric\u done);
discouse.setOnClickListener((视图v)->done());
this.maxLength=maxLength;
NumericiInputManager=新的NumericiInputManager(最大长度);
intStack=新堆栈();
valueEnteredTV=root.findViewById(R.id.value\u输入);
初始化按钮();
initRestrictions();
}
在您的AppTheme上添加@style/CustomDialog
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:dialogTheme">@style/CustomDialog</item>
</style>
@样式/自定义对话框