我有一個probleme,我從JSON一文中,我分析它,但我需要從這個文本PIC的形象,這就是JSON文本:IMG從TextView的
"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\" />
,我想從這個文本PIC圖片與文字顯示出來,如果有一個人能幫助我,我不知道該怎麼做,我嘗試,但什麼也沒發生。
這是我收杆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;
}
,這是隻顯示文本。
什麼問題?你知道內容的格式是什麼,只是解析它並獲取URL。如果您有特定問題,請發佈您的代碼。 – 2013-04-11 14:57:22
是的,我解析它,但問題我不能顯示我解析文本,但圖片不是,我應該從文本分離img並顯示它與文本 – Sherlock 2013-04-11 15:03:00
請顯示您的代碼 – 2013-04-11 15:04:35