【发布时间】:2012-01-23 05:55:45
【问题描述】:
我想在列表视图中显示某个 youtube 频道的视频,并允许用户选择其中一个视频进行观看。是否有任何可用的 Json 数据。
编辑
JSONObject json = JSONfunctions.getJSONfromURL("http://gdata.youtube.com/feeds/api/videos?
author=NationalGeographic&v=2&alt=json");
try{
JSONArray earthquakes = json.getJSONArray("feed");
for(int i=0;i<earthquakes.length();i++){
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = earthquakes.getJSONObject(i);
map.put("id", String.valueOf(i));
map.put("name", "Earthquake name:" + e.getString("eqid"));
map.put("magnitude", "Magnitude: " + e.getString("magnitude"));
mylist.add(map);
}
}catch(JSONException e) {
Log.e("log_tag", "Error parsing data "+e.toString());
}
我有权限并且 url 在 tab 中工作,我收到 nullpointer 错误 @JSONArray 地震 = json.getJSONArray("feed");
【问题讨论】:
-
首先,您使用了错误的 URL。请参考我的回答。