Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay HTML Formatted String
    primarykey
    data
    text
    <p>I need an example of how to display the strings that I have marked up with simple html into a TextView. I have found "Spanned fromHtml(String source)", but I don't know how to plug it into my java code.</p> <p>Here is my Java:</p> <pre><code>package com.SorenWinslow.TriumphHistory; import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; public class TriumphHistory extends ListActivity { String[] HistoryList; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArrayAdapter&lt;String&gt; adapter; HistoryList = getResources().getStringArray(R.array.history); adapter = new ArrayAdapter&lt;String&gt; (this,R.layout.historylistlayout,HistoryList); setListAdapter(adapter); } } </code></pre> <p>Here is a sample of history:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string-array name="history"&gt; &lt;item&gt;&lt;b&gt;1883&lt;/b&gt;&lt;br/&gt;Some stuff happened&lt;/item&gt; &lt;item&gt;&lt;b&gt;1884&lt;/b&gt;&lt;br/&gt;Some more stuff happened &lt;i&gt;before&lt;/i&gt; the other stuff &lt;/item&gt; &lt;resources&gt; </code></pre> <p>Here is my historylistlayout.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_vertical" android:textColor="#ffffff" android:background="#000050" android:layout_marginTop="5px" android:minHeight="?android:attr/listPreferredItemHeight" android:padding="3px" android:textSize="8pt" android:layout_gravity="top|left"/&gt; </code></pre> <p>And here is my main.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:textColor="#ffffff" android:background="#000080" android:isScrollContainer="true" android:layout_height="fill_parent" android:layout_width="fill_parent" android:scrollbarStyle="insideOverlay"&gt; &lt;ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true" android:dividerHeight="1px"/&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload