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/