Денис Климков Денис Климков - 4 months ago 14
Android Question

How to change the color of text programmatically with JSON

I have JSON file with object "status". Status has got 3 parameters: id, title, color.
My Model:

public int StatusId;
public String StatusTitle;
public String StatusColor;


My GetHelper:

JSONObject status = data.getJSONObject("status");
orderDetails.StatusId = status.getInt("id");
orderDetails.StatusTitle = status.getString("title");
orderDetails.StatusColor = status.getString("color");


When I get my string with color, I want put it. For this I do it:

statusTextView.setTextColor(mOrderDetailsInfo.StatusColor);


But It's not working.
I will be glad to any advice.

Answer
statusTextView.setTextColor(Color.parseColor(mOrderDetailsInfo.StatusColor));