gpt4 book ai didi

android - 在 Android 的 alertdialog builder 中显示 html 文件

转载 作者:行者123 更新时间:2023-11-29 20:42:27 26 4
gpt4 key购买 nike

final AlertDialog d = new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_launcher)
.setCancelable(false) // Cant Be Cancel By Pressing Back Key Only By Pressing Positive Button
.setTitle("About") // Can Also Be Done By HTML Style
.setPositiveButton(android.R.string.ok, null)
.setMessage(Html.fromHtml("<i> etc etc stuff"))
.create();
d.show();

但我的 raw 文件夹中有 html 文件,我想显示 html 文件的格式正确,并且我已将所有必需的转义序列(如 etc 内容)放入我的 raw 文件夹中的 html 文件中

我真正想要的是在.setMessage中显示html文件。像 getResources().open 这样的东西对我不起作用

我该怎么做?

最佳答案

i used to use this code written above but i have html file in my raw folder which i want to display html file is properly formatted and i have put all the required escape sequences like etc stuff in html file which is in my raw folder

您可能想使用 WebView :

WebView webView = new WebView(this);
webView.loadUrl("file:///android_res/raw/your_file_name.html");

而不是

.setMessage(Html.fromHtml("<i> etc etc stuff"))

使用

.setView(webView)

关于android - 在 Android 的 alertdialog builder 中显示 html 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30821868/

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