我没有从JSON获取图像。
如何获得" LogoFileName"来自我的JSON的图片。我只得到标题和描述。但我也需要LogoFileName。 如果有任何机构知道任何解决方案,请帮助我。
代码:
{"Channels":[{"AlertDetailsFont":"","AlertDetailsFontId":0,"AlertHeaderFont":"","AlertHeaderFontId":0,"Category":"Education","CategoryId":7,"ChannelId":53,"Color1":"Red","Color2":"Black","Color3":"Black","Color4":"","Color5":"","ColorCode1":"FF0000","ColorCode2":"000000","ColorCode3":"000000","ColorCode4":"","ColorCode5":"","ColorId1":1,"ColorId2":3,"ColorId3":3,"ColorId4":0,"ColorId5":0,"Description":"This must be visible now","FontSize":"12px","FontSizeId":1,"HeaderFont":"Arial","HeaderFontId":2,"IsBold":false,"IsItalic":false,"LogoFileName":"http:\/\/183.82.97.146:1111\/CAWebsite\/UserImages\/ChannelLogos\/02022012_170628.jpg","ModifiedBy":12,"ModifiedDate":"\/Date(1328182588000+0530)\/","ModifiedUsername":"skrt","PublicChannelId":"f12d79aa-4267-11e1-a94b-0021706baaba","TickerFont":"","TickerFontId":0,"Title":"Books"},,.................etc
嗨,这是我的代码..
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="6dip"
android:src="@drawable/icon" />
<TextView
android:id="@+id/item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/icon"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="@+id/icon"
android:gravity="center_vertical"
android:text="My Application" />
<TextView
android:id="@+id/item_subtitle"
android:layout_width="fill_parent"
android:layout_height="26dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/icon"
android:ellipsize="marquee"
android:singleLine="true"
android:text="Simple application that shows how to use RelativeLayout" />
</RelativeLayout>
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
JSONObject json = JSONfunctions.getJSONfromURL("http://my path...");
try{
JSONArray channels = json.getJSONArray("Channels");
for(int i=0;i<channels.length();i++){
HashMap<String, String> map = new HashMap<String, String> ();
JSONObject e = channels.getJSONObject(i);
map.put("id", String.valueOf(i));
map.put("name", e.getString("Title"));
map.put("Category", e.getString("Category"));
//map.put("imageUrl", e.getString("LogoFileName"));
imageUrl= e.getString("LogoFileName");
System.out.println("Logo Url:"+imageUrl);
mylist.add(map);
}
}catch(JSONException e)
{
Log.e("log_tag", "Error parsing data "+e.toString());
}
ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main,
new String[] { "name", "Category" },
new int[] { R.id.item_title, R.id.item_subtitle });
setListAdapter(adapter);
final ListView lv = getListView();
lv.setTextFilterEnabled(true);