简体   繁体   English

如何从php web服务在android webview中显示html代码

[英]how to show html code in android webview from php web service

I have an android application that application takes data from my php json web service. 我有一个Android应用程序,该应用程序从我的php json网络服务获取数据。 How can my php service give my json data to my android apk to show html content true. 我的php服务如何将json数据提供给我的android apk以显示html内容为true。 My android apk using textview to show my text content. 我的Android APK使用TextView显示我的文本内容。

I used " \\n " or " <br> " but its not working. 我使用了“ \\n ”或“ <br> ”,但是它不起作用。

mysql $desc = 'satir1\nsatir2\n' ; 
//or $desc = 'satir1<br />satir2<br />' ;
$desc = trim(htmlspecialchars_decode($desc)) ; 
mysql insert into ........

First thing you have to do is create a webview as follows http://developer.android.com/reference/android/webkit/WebView.html 您要做的第一件事是创建一个Web视图,如下所示: http://developer.android.com/reference/android/webkit/WebView.html

Then use load the json content using the loadDatawithBaseURL.. example http://www.codota.com/android/methods/android.webkit.WebView/loadDataWithBaseURL 然后使用loadDatawithBaseURL来加载json内容。例如http://www.codota.com/android/methods/android.webkit.WebView/loadDataWithBaseURL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM