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?
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.
首先你创建CustomAdapter for listView像这样http://www.pocketmagic.net/?p=1343并在textview中
<TextView android:textStyle="bold|italic"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.