我正在尝试创建一个内容丰富的AlertDialog
。
当我使用 Html.fromHtml()
设置消息文本时,如下所示:
AlertDialog.Builder adb = new AlertDialog.Builder(this);
adb.setTitle("title");
adb.setMessage(Html.fromHtml(text));
它只允许我使用基本的 HTML 元素,例如 (粗体)和
(斜体)。
当我使用像这样的WebView
时
WebView webView = new WebView(this);
myWebView.loadData(webContent, "text/html", "utf-8");
AlertDialog.Builder adb = new AlertDialog.Builder(this);
adb.setView(webView);
我丢失了默认的 Android 样式。
如何获取丰富的上下文,例如 AlertDialog
内的
?。
最佳答案
您可以在 Activity 中添加 WebView,并在 menifest 文件中将 Activity 主题设置为对话框:
<activity .....
android:theme="@android:style/Theme.Dialog"/>
关于android - 将 WebView 显示为 AlertDialog 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14999932/