我有一个ListView,我想从url加载图像,其中图像名称是ID.jpg(例如:1.jpg / 2.jpg / 3.jpg等)。 ID来自数据库,但是所有行加载到ListView中的图像都是一个图像(1.jpg)。
public override bool Equals(SuperClass dictKeyComparerA, SuperClass dictKeyComparerB)
{
var a = dictKeyComparerA as SubClass;
var b = dictKeyComparerB as SubClass;
return a.application == b.application;
}
public override int GetHashCode(SuperClass dictKeyComparer)
{
return application.GetHashCode();
}
txtDate.setText(Request_Date.get(position));
txtTime.setText(Request_Time.get(position));
//ivImage.setImageResource(imgid[position]); <-- this works from drawable and not from database
Picasso.with(context).load(url_poster + request_eventID + ".jpg").into(ivImage);
是来自DB的ID,这是我的问题,它只返回1(而不是其余的ID),因此只有1.jpg被加载到所有行的ListView中。
编辑:
我如何检索ID
request_eventID
请注意,如果我执行JSONObject jsonResponse = new JSONObject(jsonResult);
JSONArray jsonMainNode = jsonResponse.optJSONArray("read_columns");
for (int i = 0; i < jsonMainNode.length(); i++) {
JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
String request_date = jsonChildNode.optString("Date");
String request_time = jsonChildNode.optString("Time");
request_eventID = jsonChildNode.optString("EID");
arrRequest_Date.add(request_date);
arrRequest_Time.add(request_time);
arrRequest_EID.add(request_eventID);
答案 0 :(得分:0)
好的,就像我怀疑的那样,我玩了一些代码,确实得到了(位置)我需要的ID。
解决方案:
Picasso.with(context).load(url_poster + Request_EID.get(position) + ".jpg").into(ivImage);
谢谢大家的回复。