Tejaswini
Tejaswini

Reputation: 357

Dynamically change to bold and italic in listview android

I am developing a chat application.Here for chat i have used ListView . I want to set bold and italic options for the text of ListView dynamically. setTypeFace is not working for it . How can i do that?

Upvotes: 3

Views: 3484

Answers (2)

colegu
colegu

Reputation: 370

setTypeFace works. You have to set it in the adapter on the getView() method. For getView to get called you should use adapter.notifyDataSetChanged();

TextView eventText = (TextView) v.findViewById(R.id.eventText);
    if (eventText != null)
    {
        eventText.setText(event.getUserName());
        if (event.isNew()) eventText.setTypeface(null, Typeface.BOLD);
        else eventText.setTypeface(null, Typeface.NORMAL);

    }

Here is an example I used for the setTypeFace() method. This code is in the getView method of the adapter.

Upvotes: 3

Samir Mangroliya
Samir Mangroliya

Reputation: 40416

First You Create CustomAdapter For listView Like this http://www.pocketmagic.net/?p=1343 And in textview

<TextView android:textStyle="bold|italic"/>

Upvotes: 2

Related Questions