我正在为Android编写一个简单的应用程序,我想在AlertDialog
的{{1}}中使用自定义ListPreference
(没有否定按钮,更改字体大小),所以我扩展{ {1}}像这样:
PreferenceScreen
然后我点击ListPreference
,public class ListPreferenceEx extends ListPreference {
public ListPreferenceEx(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder); // To change body of overridden
builder.setNegativeButton(null, null);
builder.setTitle(null);
}
}
弹出,不带标题&否定按钮,就像弹出菜单一样。但是,我不知道如何更改此列表的字体大小。我知道ListPreferenceEx
可以使用布局,但仅限于构造函数:
list(AlertDialog)
当我将上述代码放入onPrepareDialogBuilder并运行它时,我无法得到正确的结果:
案例1 :(完全没有列表显示)
AlertDialog.Builder
案例2 :(无效,字体大小不变)
builder = new AlertBuilder(new ContextThemeWrapper(this.getContext(), R.style.xxxTheme));
如何在builder = new AlertDialog.Builder(new ContextThemeWrapper(this.getContext(), R.style.ListDlgTheme));
super.onPrepareDialogBuilder(builder);
或其他覆盖方法中设置super.onPrepareDialogBuilder(builder);
builder = new AlertDialog.Builder(new ContextThemeWrapper(this.getContext(), R.style.ListDlgTheme));
字体大小?或者在AlertDialog.Builder's
中使用自定义onPrepareDialogBuilder
?请帮助我,谢谢!