[android-beginners] Re: Help with displaying HTML formatted strings from an ArrayAdapter

2010-03-26 Thread PKC
Try this:


String[] plainStrings =
getResources().getStringArray(R.array.history);
Spanned[] htmlStrings = new Spanned[plainStrings.length];
for(int i = 0 ; i  plainStrings.length; i++) {
htmlStrings[i] = Html.fromHtml(plainStrings[i]);
}
setListAdapter(new ArrayAdapterCharSequence(this,
R.layout.list_item, htmlStrings));




On Mar 23, 11:12 am, Soren soren.wins...@comcast.net wrote:
   I appologize for the absolute beginner questions, but I am having a
 tough time understanding this.

   I need somehelpof how to display the strings that I have marked up
 with simplehtmlinto 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:

 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);

         ArrayAdapterString adapter;
         HistoryList = getResources().getStringArray(R.array.history);
         adapter = new ArrayAdapterString
 (this,R.layout.historylistlayout,HistoryList);
         setListAdapter(adapter);

     }

 }

 Here is a sample of history:

 ?xml version=1.0 encoding=utf-8?
 resources
 string-array name=history
 itemb1883/bbr/Some stuff happened/item
 itemb1884/bbr/Some more stuff happened ibefore/i the other
 stuff
 /item
 resources

 ?xml version=1.0 encoding=utf-8?
 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=#ff
     android:background=#50
     android:layout_marginTop=5px
     android:minHeight=?android:attr/listPreferredItemHeight
     android:padding=3px
     android:textSize=8pt android:layout_gravity=top|left/

 And here is my main.xml

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
     android:orientation=vertical
     android:textColor=#ff
     android:background=#80
     android:isScrollContainer=true
     android:layout_height=fill_parent
     android:layout_width=fill_parent
 android:scrollbarStyle=insideOverlay

   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/

 /LinearLayout

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.


[android-beginners] Re: Help with displaying HTML formatted strings from an ArrayAdapter

2010-03-26 Thread PKC
try this:

...
String[] plainStrings =
getResources().getStringArray(R.array.history);
Spanned[] htmlStrings = new Spanned[plainStrings.length];
for(int i = 0 ; i  plainStrings.length; i++) {
htmlStrings[i] = Html.fromHtml(plainStrings[i]);
}
setListAdapter(new ArrayAdapterCharSequence(this,
R.layout.list_item, htmlStrings));
...


On Mar 23, 11:12 am, Soren soren.wins...@comcast.net wrote:
   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:

 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);

         ArrayAdapterString adapter;
         HistoryList = getResources().getStringArray(R.array.history);
         adapter = new ArrayAdapterString
 (this,R.layout.historylistlayout,HistoryList);
         setListAdapter(adapter);

     }

 }

 Here is a sample of history:

 ?xml version=1.0 encoding=utf-8?
 resources
 string-array name=history
 itemb1883/bbr/Some stuff happened/item
 itemb1884/bbr/Some more stuff happened ibefore/i the other
 stuff
 /item
 resources

 ?xml version=1.0 encoding=utf-8?
 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=#ff
     android:background=#50
     android:layout_marginTop=5px
     android:minHeight=?android:attr/listPreferredItemHeight
     android:padding=3px
     android:textSize=8pt android:layout_gravity=top|left/

 And here is my main.xml

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
     android:orientation=vertical
     android:textColor=#ff
     android:background=#80
     android:isScrollContainer=true
     android:layout_height=fill_parent
     android:layout_width=fill_parent
 android:scrollbarStyle=insideOverlay

   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/

 /LinearLayout

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.


[android-beginners] Re: Help with displaying HTML formatted strings from an ArrayAdapter

2010-03-26 Thread rsung
test

On Mar 23, 11:12 am, Soren soren.wins...@comcast.net wrote:
   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:

 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);

         ArrayAdapterString adapter;
         HistoryList = getResources().getStringArray(R.array.history);
         adapter = new ArrayAdapterString
 (this,R.layout.historylistlayout,HistoryList);
         setListAdapter(adapter);

     }

 }

 Here is a sample of history:

 ?xml version=1.0 encoding=utf-8?
 resources
 string-array name=history
 itemb1883/bbr/Some stuff happened/item
 itemb1884/bbr/Some more stuff happened ibefore/i the other
 stuff
 /item
 resources

 ?xml version=1.0 encoding=utf-8?
 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=#ff
     android:background=#50
     android:layout_marginTop=5px
     android:minHeight=?android:attr/listPreferredItemHeight
     android:padding=3px
     android:textSize=8pt android:layout_gravity=top|left/

 And here is my main.xml

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
     android:orientation=vertical
     android:textColor=#ff
     android:background=#80
     android:isScrollContainer=true
     android:layout_height=fill_parent
     android:layout_width=fill_parent
 android:scrollbarStyle=insideOverlay

   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/

 /LinearLayout

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.


[android-beginners] Re: Help with displaying HTML formatted strings from an ArrayAdapter

2010-03-26 Thread rsung
test

On Mar 23, 11:12 am, Soren soren.wins...@comcast.net wrote:
   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:

 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);

         ArrayAdapterString adapter;
         HistoryList = getResources().getStringArray(R.array.history);
         adapter = new ArrayAdapterString
 (this,R.layout.historylistlayout,HistoryList);
         setListAdapter(adapter);

     }

 }

 Here is a sample of history:

 ?xml version=1.0 encoding=utf-8?
 resources
 string-array name=history
 itemb1883/bbr/Some stuff happened/item
 itemb1884/bbr/Some more stuff happened ibefore/i the other
 stuff
 /item
 resources

 ?xml version=1.0 encoding=utf-8?
 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=#ff
     android:background=#50
     android:layout_marginTop=5px
     android:minHeight=?android:attr/listPreferredItemHeight
     android:padding=3px
     android:textSize=8pt android:layout_gravity=top|left/

 And here is my main.xml

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
     android:orientation=vertical
     android:textColor=#ff
     android:background=#80
     android:isScrollContainer=true
     android:layout_height=fill_parent
     android:layout_width=fill_parent
 android:scrollbarStyle=insideOverlay

   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/

 /LinearLayout

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.