android 版本:4.2 我的示例代码是:
try {
//HttpResponse response = httpClient.execute(httpGet, localContext);
HttpResponse response = httpClient.execute(httpGet, localContext);
HttpEntity entity = response.getEntity();
text = getASCIIContentFromEntity(entity);
text=text.replaceAll("<", "<").replace(">", ">").replace(" ", " ");
int start=text.indexOf("<message>");
start=start+9;
int end=text.indexOf("</message>");
text=text.substring(start, end);
JSONArray ja = new JSONArray(text) ;
// ITERATE THROUGH AND RETRIEVE CLUB FIELDS
int n = ja.length();
for (int i = 0; i < 1; i++) {
// GET INDIVIDUAL JSON OBJECT FROM JSON ARRAY
JSONObject jo = ja.getJSONObject(i);
title+= jo.getString("Title")+",";
url= jo.getString("URL");
desc= jo.getString("Description");
}
} catch (Exception e) {
return e.getLocalizedMessage();
}
问题:变量 desc(即,我的 json 中的描述)包含** **
在其内容中。我已使用以下代码将 HTML 转换为 android 中的字符串:
Spanned marked_up = Html.fromHtml(results);
tv2.setText(marked_up.toString(),BufferType.SPANNABLE);
它仍然没有取代** **
. 请帮助我。先感谢您。