Reputation: 575
I am working on android applications. In my app I am getting the html content and setting it to text view. My html data is displaying in the textview but at one point it stopped. i .e only half of the paragraph is displaying in the textview.
The data is "The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (TCP/IP) to serve several billion users worldwide. It is a network of networks that consists of millions of private, public, academic, business, and government networks, of local to global scope, that are linked by a broad array of electronic, wireless, and optical networking technologies. The (water A1c <5.0) may be detrimental in certain populations, such as the elderly and those with cardiovascular disease."
In the above paragraph upto "The (water A1c" the data is displaying in the textview and from there the data is not displaying. Th remaning data is cutted. I tried to trim the data but it didnt work. Please give me any suggestions for this.
Mycode:
Textview.setText((Html.fromHtml(data)));
The below content is being cut in the textview. It is not displaying.
<5.0) may be detrimental in certain populations, such as the elderly and those with cardiovascular disease."
Upvotes: 0
Views: 97
Reputation: 40
As Aby Mathew suggested, you can display your data in TextView if you replace < by its HTML equivalent
Code that can be used:
data=data.replace("<","<");
Textview.setText((Html.fromHtml(data)));
Hope it helps :)
Upvotes: 0
Reputation: 8520
Actually it is the problem with the <
symbol.
Just use the ASCII value of <
symbol. and that is <
.
Take a look here for more ASCII values.
Hope this will help. :)
Upvotes: 0
Reputation: 5234
Try something like below.
((TextView)findViewById(R.id.text)).setText(Html.fromHtml("Hello Everyone"));
Upvotes: 0
Reputation: 3975
String htmlStr = "<b>" +
context.getResources().getString(R.string.yourText)+
"</b>";
textView.setText(Html.fromHtml(htmlStr));
Upvotes: 1
Reputation: 4547
TextView myTextview;
myTextview= (TextView) findViewById(R.id.my_text_view);
htmltext = <your html (markup) character>;
Spanned sp = Html.fromHtml( htmltext );
myTextview.setText(sp);
Upvotes: 0