2016-03-31 111 views
0

我有一个ListView,我想从其中加载图像的图像名称是一个ID.jpg(例如:1.jpg/2.jpg/3.jpg ..等) 。这些ID来自数据库,但是加载到我所有行的ListView中的图像都是一个图像(1.jpg)。Android从URL加载图像到ListView

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); 

request_eventID来自DB的ID,这是我的问题,它只返回1(而不是ID的其余部分),所以因此仅1.JPG装入的所有行ListView控件。

编辑:

我如何检索标识

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); 

注意,我可以看到所有的ID,如果我做一个System.out.println("IDs" +request_eventID)

+1

什么是你的sql查询检索数据 – satyapol

+0

请发布你在哪里和如何得到“request_eventID”? –

回答

0

好了,正如我怀疑,我的代码发挥各地有一点,实际上得到(位置)是我需要的ID。

解决方案:

Picasso.with(context).load(url_poster + Request_EID.get(position) + ".jpg").into(ivImage); 

谢谢大家的响应。