Android:在列表视图中设置图标
目前,我有几个twitter提要的json数据,我通过解析这些数据来填充我的列表。我有一个对象,图像,它包含我想在列表中设置为ImageView的用户图标的url。我在尝试找出如何获取url并在Imageview中为每行加载图像时遇到问题。代码如下:Android:在列表视图中设置图标,android,json,listview,icons,gson,Android,Json,Listview,Icons,Gson,目前,我有几个twitter提要的json数据,我通过解析这些数据来填充我的列表。我有一个对象,图像,它包含我想在列表中设置为ImageView的用户图标的url。我在尝试找出如何获取url并在Imageview中为每行加载图像时遇到问题。代码如下: public void getTweets(String selection) { String formatedcat = selection.toLowerCase(); ArrayList<HashMap
public void getTweets(String selection) {
String formatedcat = selection.toLowerCase();
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
JSONObject json = JSONfunctions
.getJSONfromURL("http://example.com/tweet.php");
try {
JSONArray category = json.getJSONArray(formatedcat);
for (int i = 0; i < category.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject c = category.getJSONObject(i);
map.put("id", String.valueOf(i));
map.put("name",
c.getString("fullName") + "\n(#" + c.getString("name")
+ ") ");
map.put("text",
c.getString("text") + "\n - "
+ c.getString("timestamp"));
mylist.add(map);
}
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.list,
new String[] { "name", "text"}, new int[] { R.id.item_title,
R.id.item_subtitle});
setListAdapter(adapter);
final ListView lv = getListView();
lv.setTextFilterEnabled(true);
}
看这个问题。我觉得很实用。在getView方法中显示图像,在该方法中填充列表并实例化子视图。那么你说你有图像的url,对吗?是的,它们都与此类似:嘿,我遇到的真正问题是如何将url获取到我的图像管理器,并将其设置为不同的次数。我试过map.putimage,c.getStringimage;但我不知道如何将该值添加到imagemanager函数中。这有意义吗?当您登录.iIMAGE:,c.getStringimage;你看到网址了吗?很好。现在,按照我告诉您的,在getView中实例化imageview,对图像进行处理,因为您拥有所有URL。执行类似urlist.getposition的操作;因此,每个项目有一个url,因此每个项目有一张图片。你明白我的意思了吗?