Here is a solution specific to your case:
Update your code as follows:
JSONArray jArray= new JSONArray(result); Spanned spannedStr = null; for(int i=0; i<jArray.length();i++) { JSONObject getjson = jArray.getJSONObject(i); spannedStr = (Spanned) TextUtils.concat(getColorString("Title:"), getjson.getString("tender_title"), "\n\n", getColorString("Tender id:"), getjson.getString("tender_title"), "\n\n", getColorString("Reference no:"), getjson.getString("tender_title"), "\n\n", getColorString("Quantity:"), getjson.getString("tender_title")); } TextView txt=(TextView) findViewById(R.id.textView1); txt.setText(spannedStr);
Define a helper method in the same class and use it:
private Spanned getColorString(String str) { return Html.fromHtml("<font color='#FFFF00'>" + str + "</font>"); }
Output Example:

Amulya khare
source share