gpt4 book ai didi

android - AlertDialog主题问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:13:49 26 4
gpt4 key购买 nike

我正在创建一个 AlertDialog。如果这样创建:

AlertDialog.Builder builder = AlertDialog.Builder((RelationActivity)getContext());
builder.setMessage("No relations found.");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
((RelationActivity)getContext()).finish();
}
});
builder.create();
builder.show();

这是结果:http://www.ozze.com.br/1.png

但是,如果我尝试设置一个主题,就像这样:

AlertDialog.Builder builder = new AlertDialog.Builder(((RelationActivity)getContext()), android.R.style.Theme_Holo_Light_Dialog);

这是结果:http://www.ozze.com.br/2.png

拜托,有人可以帮我解决这个问题吗?看起来在使用主题时,主题“包围”了警报对话框。

最佳答案

要为 Theme.Holo.Light 等警报对话框设置不同的主题,请尝试使用 Android 源代码中 Dialog.java 中使用的 ContextThemeWrapper:

builder = new AlertDialog.Builder(new ContextThemeWrapper(this, android.R.style.Theme_Holo_Light_Dialog))

关于android - AlertDialog主题问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12886399/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com