2013-09-22 197 views
0

我從網頁中檢索一些html源代碼。當我使用Html.showHtml(htmlSource); 時,它不能正確顯示圖形。 這裏是圖的樣子在網絡上,沒有着色:Android顯示textview圖

Day Date Time Event       Location 
Fri Sep 27 4:00 PM Practice     MSC Yellow 
Sun Sep 29 3:00 PM MJBL Game vs Runnin Rebels MSC Yellow 

這裏是圖中的HTML和CSS:

<table class="gymschedule"> 
    <colgroup> 
     <col /> 
     <col /> 
     <col /> 
     <col /> 
     <col width="10" /> <!-- small! --> 
     <col /> 
     <col /> 
    </colgroup> 
    <thead> 

        <tr> 
      <td> 
       <nobr>Fri</nobr> 
      </td> 
      <td> 
       <nobr>Nov 1</nobr> 
      </td> 
      <td> 
       <nobr>4:00 PM</nobr> 
      </td> 
      <td> 
       Practice    </td> 
      <td> 
       <nobr>MSC Yellow</nobr> 
      </td> 
     </tr> 
        <tr> 
      <td> 
       <nobr>Fri</nobr> 
      </td> 
      <td> 
       <nobr>Nov 8</nobr> 
      </td> 
      <td> 
       <nobr>4:00 PM</nobr> 
      </td> 
      <td> 
       Practice    </td> 
      <td> 
       <nobr>MSC Yellow</nobr> 
      </td> 
     </tr> 
       </tbody> 
</table> 

我怎麼可以在文本或圖像顯示該圖在Android手機上正確查看?

回答

0

Android TextView不支持<table>標記及其關聯的標記。有關TextView支持的HTML標記列表,請參閱here

要顯示此信息,您需要使用WebView。首先,web視圖添加到您的佈局:

<WebView 
    android:id="@+id/webView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" /> 

然後加載相關的活動表HTML:

String html = "<table> ..... </table>"; 

WebView webView = (WebView)findViewById(R.id.webView); 
webView.loadData(html, "text/html", "utf-8");