如何在Android WebView中显示html表

时间:2014-05-19 11:54:28

标签: android webview

我的Android WebView存在问题。我想在我的WebView中显示http://www.azems.az/admin/get_item_data.php?lang=0&item=RQ245309883SG链接。但它没有html标签,因此我无法将其显示为html页面。我怎么解决这个问题?求你帮帮我。

2 个答案:

答案 0 :(得分:2)

WebView wv = (WebView) findViewById(R.id.webView1);

String str = "<table width='740' border='0' align='center' cellspacing='0' cellpadding='0'><tr><td width='80%' align='left' valign='top'><left><font face='Arial, Helvetica, sans-serif' size='3' color='#0363CA'><b>G&#246;nd&#601;ri&#351;in izl&#601;nilm&#601;si</b></font></center><br><table width='740' border='0' align='center' cellspacing='1' cellpadding='1' bgcolor='#cccccc' bordercolor='#FFFFFF'  <tr> <tr bgcolor='#0363CA'>     <td colspan=4 height='30' align='left'><font face='Arial, Helvetica, sans-serif' size='2' color='#FFFFFF'><b>&nbsp;G&#246;nd&#601;ri&#351;in n&#246;mr&#601;si:&nbsp;&nbsp;RQ245309883SG&nbsp;&nbsp;&nbsp;&nbsp; T&#601;yinat yeri:&nbsp;&nbsp;AZERBAIJAN</b></font></td>  </tr><tr height='25' bgcolor='F79B20'>     <td width= '75' align='center'><font face='Arial, Helvetica, sans-serif' size='2'><b>Tarix</b></font></td>       <td width= '75' align='center'><font face='Arial, Helvetica, sans-serif' size='2'><b>Vaxt</b></font></td>      <td align='center'><font face='Arial, Helvetica, sans-serif' size='2'><b>Status</b></font></td>      <td width= '170' align='center'><font face='Arial, Helvetica, sans-serif' size='2'><b>M&#601;nt&#601;q&#601</b></font></td> </tr><tr height='25' bgcolor='#EDEEEE'>     <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;19.04.2014&nbsp;</font></td>               <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;15.23&nbsp;</font></td>     <td align='left' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;G&ouml;nd&#601;r&#601;n &ouml;lk&#601;nin m&uuml;badil&#601; m&#601;nt&#601;q&#601;sind&#601;n yola sal&#305;n&#305;b&nbsp;</font></td>     <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;SGSINJ&nbsp;</font></td> </tr><tr height='25' bgcolor='#C6C7CA'>     <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;25.04.2014&nbsp;</font></td>               <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;19.11&nbsp;</font></td>     <td align='left' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;T&#601;yinat &ouml;lk&#601;sinin m&uuml;badil&#601; m&#601;nt&#601;q&#601;sin&#601; daxil olub&nbsp;</font></td>     <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;AZBAKA&nbsp;</font></td> </tr><tr height='25' bgcolor='#EDEEEE'>     <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;29.04.2014&nbsp;</font></td>               <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;11.15&nbsp;</font></td>     <td align='left' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;&Ccedil;atd&#305;r&#305;l&#305;b, al&#305;c&#305;: &nbsp;</font></td>     <td align='center' valign='center'><font face='Arial, Helvetica, sans-serif' size='2'>&nbsp;AZ1110&nbsp;</font></td> </tr><tr height='25' bgcolor='#E2E4E5'> </tr></table>     </td>  </tr></table> ";

wv.loadDataWithBaseURL(null, str, "text/html", "UTF-8", null);

答案 1 :(得分:0)

只需从链接中获取所有数据,然后

webview.loadData(Html.fromHtml(yourdata), "text/html", "UTF-8");

那就是......