Problem with special characters in Android text

I have a text view in an Android application, the text of the text view is populated from an API request, the response of this API is just text, but this text can have special characters, such as an apostrophe or any other special character.

The problem is that when the answer has special characters, the text view only displays that special character and that after it examples:

When is the answer Capt. Tony's Capt. Tony's , the text view displays only the 's .

When the answer is Golf Club , the text view works fine and displays Golf Club

When the answer is Café 28 , only é 28 is displayed in the text view

And I know that the answer is correct, because I have tested it too many times.

MY TEXT VIEW CODE:

XML

 <TextView android:id="@+id/item_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello world" android:textColor="#ffffff" android:textSize="18sp" android:layout_marginLeft="10dp"/> 

Java

 TextView item_name = (TextView) rowView.findViewById(R.id.item_name); item_name.setText(item.getTitle()); 

Any help would be greatly appreciated.

+4
source share
1 answer

Try

 TextView item_name = (TextView) rowView.findViewById(R.id.item_name); item_name.setText(Html.fromHtml(item.getTitle())); 
+2
source

All Articles