1

If my json file is

[{name:xxxb fname:dddd tag1:F no:43434},{name:yyy fname:dfff tag1:T no:46464},{name:bbbb fname:nnnn tag1:F no:76676},{name:trtr fname:ghgh tag1:T no:5666}]

and so on I am getting the all the display in the listview in eclipse android emulator but how do I change the color of my json value 'add'. In other words if the json value add:F then F should be shown in red in my listview else if the add:T then T should be shown in red.

1 Answers1

-1

Please check out this API:

JSONObject jsonObject;
String color, item;
String str = "<font color=\"%s\">%s</font>";
// handle the exception here
item = jsonObject.getString("add")
if("F".equalsIgnoreCase(item)){
   color = "red";
}else if("T".equalsIgnoreCase(item)){
   color = "green";
}else{
    color = "blue";
}
// and inside your ArrayAdapter
itemTextView.setText(Html.fromHtml(String.format(Locale.US, str, color, item)));
TheRealChx101
  • 1,468
  • 21
  • 38