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

标签 android html

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/

相关文章:

html - 边框不覆盖图片

javascript - 访问 .innerHTML 中的不同对象问题

html - 我无法使用 HTML 中的 <hr> 标记添加一行

android - 使用ContentValues插入SQLite DB失败

android - 动态创建布局(类似于listview)

java - Imageview 没有显示我的图像?

javascript - Textarea 不会使用所见即所得编辑器提交到 MySQL?

css - 100% Height Div 在另一个 100% div 内

android - 蓝牙低功耗 - 多个 TI 传感器标签连接

android - multidex错误不断崩溃