2015-11-06 43 views
0

我有一个标题对话框。当不使用主题,它的作品:将主题应用于对话框后,未显示标题

Dialog dialog = new Dialog(this); 
dialog.setTitle("My dialog"); 

但是,我应用了一个主题后,它不再显示标题,我不明白为什么。

Dialog dialog = new Dialog(this, R.style.Theme_AppCompat_Light_Dialog); 
dialog.setTitle("My dialog"); 
+1

它似乎是一个[错误](https://code.google.com/p/android/issues/detail?id=79097)。 – Blackbelt

+0

如果您使用DialogFragment,该怎么办? –

回答

0

尝试用DialogBuilder

AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.R.style.Theme_AppCompat_Light_Dialog); 
builder.setTitle("Dialog"); 
+0

虽然没有答案,但这是一个很好的提示。我检查了AlertDialog的源代码,并且他们实际上隐藏了默认标题,并为标题使用自定义视图。也许我会这样做,以避免问题... – Oliv