我有一个问题,我有一个来自 json 的文本,我解析它,但我需要从这个文本中获取图片,这是 json 文本:
"posts": [
{
"id": 22201,
"type": "post",
"slug": "basket-le-wac-simpose-65-a-42-face-au-cmc",
"url": "http://www.wydadnews.com/?p=22201",
"status": "publish",
"title": "Basket: Le WAC s’impose 65 à 42 face au CMC",
"title_plain": "Basket: Le WAC s’impose 65 à 42 face au CMC",
"content": "<p><img alt=\"null\" src=\"http://dl.dropboxusercontent.com/u/60787184/basket8373.jpg\" align=\"left\" />Le Wydad a battu, ce soir, le CMC 65 à 42 en match comptant pour la 8e journée du championnat. Les Wydadis enchainent ainsi leur 7e victoire consécutive en championnat, sur 7 matchs disputés. <a href=\"http://www.wydadnews.com/?p=22201#more-22201\" class=\"more-link\">Read more</a></p>\n",
"excerpt": "Le Wydad a battu, ce soir, le CMC 65 à 42 en match comptant pour la 8e journée du championnat. Les Wydadis enchainent ainsi leur 7e victoire consécutive en championnat, sur 7 matchs disputés.",
"date": "2013-04-10 21:38:41",
"modified": "2013-04-11 11:23:26",
我们已经进入“内容”的网址
<p><img alt=\"null\" src=\"http://dl.dropboxusercontent.com/u/60787184/basket8373.jpg\" align=\"left\" />
我想从这个文本图片中显示图片并与文本一起显示,如果有人可以帮助我,我不知道该怎么做,我尝试但没有任何反应。
这是我的 pars json 代码,
public static Article parseArticle(JSONObject jsonArticle) {
Article article = new Article();
try {
article.setTitle(ArabicUtilities.reshape(Html.fromHtml(
jsonArticle.getString("title")).toString()));
article.setExcerpt(ArabicUtilities.reshape(Html.fromHtml(
jsonArticle.getString("excerpt")).toString()));
article.setContent(ArabicUtilities.reshape(Html.fromHtml(
jsonArticle.getString("content")).toString()));
article.setDate(jsonArticle.getString("date"));
return article;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
public static ArrayList<Article> parseArticles(String str) {
JSONObject json = null;
ArrayList<Article> list = new ArrayList<Article>();
if (str == null)
return list;
try {
JSONArray array;
json = new JSONObject(str);
array = json.getJSONArray("posts");
for (int i = 0; i < array.length(); i++) {
Article node = parseArticle(array.getJSONObject(i));
list.add(node);
}
return list;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
这是我的适配器
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)
getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.list_item, null);
TextView txtArticleTitle = (TextView) view.findViewById(R.textviews.txtArticleTitle);
TextView txtArticleExcerpt = (TextView) view.findViewById(R.textviews.txtArticleExcerpt);
TextView txtArticleDate = (TextView) view.findViewById(R.id.textArticleDate);
Article article = getItem(position);
txtArticleTitle.setText(ArabicUtilities.reshape(article.getTitle()));
txtArticleExcerpt.setText(ArabicUtilities.reshape(article.getExcerpt()));
txtArticleDate.setText(article.getDate().toGMTString());
return view;
}
这只是显示文本。