Java – How do I change the font color of a TextView in a ListView from an xml file item? Android

How do I change the font color of a TextView in a ListView from an xml file item? Android… here is a solution to the problem.

How do I change the font color of a TextView in a ListView from an xml file item? Android

Depends on the value:

Example

Payment: +200

Payment: -100

If the value of pay is higher, the color of 200 is green.
If the value of pay is low, the color of 100 is red.

It changes color every second because I have the xml file link from the browser
and update the XML file every second.
I like this color because the link in my xml file refreshes it in seconds and changes the color, depending on whether it’s high or low.

Solution

If you mean XML files for XML parsing, try the following

When you place text from an xml file in a ListView, get the colors from the xml file and parse them as follows

String txt = “<font color=#408cc4> “+”The text that needs to be printed here “+””;
viewHolder.activity_hold_heading.setText(Html.fromHtml(txt));

Here color = the color you need

Related Problems and Solutions