Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Displaying HTML formatted strings from an ArrayAdapter

Displaying HTML formatted strings from an ArrayAdapter

Put your problem here if it does not fit any of the other categories.

Displaying HTML formatted strings from an ArrayAdapter

Postby Soren » Wed Mar 24, 2010 8:30 pm

I appologize for the absolute beginner questions, but I am having a
tough time understanding this.

I need some help 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 or really how to use it. In my code below would HistoryList be my
string source?

Here is my Java:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.SorenWinslow.TriumphHistory;
  2.  
  3.  
  4.  
  5. import android.app.ListActivity;
  6.  
  7. import android.os.Bundle;
  8.  
  9. import android.widget.ArrayAdapter;
  10.  
  11.  
  12.  
  13. public class TriumphHistory extends ListActivity {
  14.  
  15.         String[] HistoryList;
  16.  
  17.        
  18.  
  19.         /** Called when the activity is first created. */
  20.  
  21.         @Override
  22.  
  23.     public void onCreate(Bundle savedInstanceState) {
  24.  
  25.         super.onCreate(savedInstanceState);
  26.  
  27.         setContentView(R.layout.main);
  28.  
  29.        
  30.  
  31.         ArrayAdapter<String> adapter;
  32.  
  33.         HistoryList = getResources().getStringArray(R.array.history);
  34.  
  35.         adapter = new ArrayAdapter<String> (this,R.layout.historylistlayout,HistoryList);
  36.  
  37.         setListAdapter(adapter);
  38.  
  39.     }
  40.  
  41. }
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


Here is a sample of history:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <resources>
  4.  
  5. <string-array name="history">
  6.  
  7. <item><b>1883</b><br/>Some stuff happened</item>
  8.  
  9. <item><b>1884</b><br/>Some more stuff happened <i>before</i> the other
  10.  
  11. stuff
  12.  
  13. </item>
  14.  
  15. <resources>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Here is my historylistlayout.xml:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <TextView xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:id="@android:id/text1"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="wrap_content"
  10.  
  11.    android:textAppearance="?android:attr/textAppearanceLarge"
  12.  
  13.    android:gravity="center_vertical"
  14.  
  15.    android:textColor="#ffffff"
  16.  
  17.    android:background="#000050"
  18.  
  19.    android:minHeight="?android:attr/listPreferredItemHeight"
  20.  
  21.    android:padding="3px"
  22.  
  23.    android:textSize="8pt"
  24.  
  25.    android:layout_gravity="top|left"
  26.  
  27.    android:clickable="true"
  28.  
  29.    android:freezesText="false"
  30.  
  31.    android:layout_marginTop="10px"/>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


And here is my main.xml

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3.  
  4.  
  5. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
  6. android"
  7.  
  8.    android:orientation="vertical"
  9.  
  10.    android:textColor="#ffffff"
  11.  
  12.    android:background="#000080"
  13.  
  14.    android:isScrollContainer="true"
  15.  
  16.    android:layout_height="fill_parent"
  17.  
  18.    android:layout_width="fill_parent"
  19.  
  20. android:scrollbarStyle="insideOverlay">
  21.  
  22.  
  23.  
  24.   <ListView xmlns:android="http://schemas.android.com/apk/res/
  25. android"
  26.  
  27.    android:id="@android:id/list"
  28.  
  29.    android:layout_width="fill_parent"
  30.  
  31.    android:layout_height="wrap_content"
  32.  
  33.    android:clickable="true"
  34.  
  35.    android:dividerHeight="1px"/>
  36.  
  37.  
  38.  
  39. </LinearLayout>
  40.  
  41.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Soren
Freshman
Freshman
 
Posts: 3
Joined: Tue Mar 23, 2010 5:32 pm

Top

Postby Soren » Thu Mar 25, 2010 2:34 pm

So, I am guessing that maybe there just isnt anyway to display html formatted array values?

Is there another way I can approach this?
Soren
Freshman
Freshman
 
Posts: 3
Joined: Tue Mar 23, 2010 5:32 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 9 guests