Reputation: 5698
I was wondering if it's possible to get the following output when using ListActivity
:
Name - Age
Name - Age
etc.
So name normal and age italic.
I'm currently using the following code:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="20sp"
android:textStyle="italic" >
</TextView>
And java:
FeedParser parser = new AndroidSaxFeedParser("http://www.example.com/test.xml");
messages = parser.parse();
List<String> titles = new ArrayList<String>(messages.size());
for (Message msg : messages){
titles.add(msg.name+"\nAge: "+msg.age+"");
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.row, titles);
this.setListAdapter(adapter);
Upvotes: 3
Views: 549
Reputation: 39604
You could simply set HTML formatted text.
Have your string look like this Bob - <i>30</i>
.
Upvotes: 0
Reputation: 1006614
Either use two TextView
widgets (one for age set to italic), or use a SpannedString
with inline markup for the italics. One way to get the SpannedString
is to use Html.fromHtml()
.
Upvotes: 2