这里我以json的形式从json接收一些图片并在listview中显示该图片,但问题是图像接收平滑慢,意味着显示1 pic和3,4秒后再显示一个和simillarly。 我想图片应该显示atonce,那么sholud我做什么?这是一些代码
protected void onPostExecute(String result){
String s = result.trim();
loadingDialog.dismiss();
JSONObject respObject;
try {
respObject = new JSONObject(s);
String active = respObject.getString("status_message");
if(active.equalsIgnoreCase("success")){
JSONArray array = respObject.getJSONArray("response");
for (int i =0; i<array.length();i++){
JSONObject jsonObject = array.getJSONObject(i);
String icon= jsonObject.getString("image");
String name = jsonObject.getString("title");
String date = jsonObject.getString("date");
id = jsonObject.getString("id");
platformno = jsonObject.getString("platform");
//this is for integer datatype receving
// id = jsonObject.getInt("id");
//platformno = jsonObject.getInt("platform");
listitem.add(new Latest_list(icon,name,date,id,platformno));
}
lv.setAdapter(new Latest_customAdpater(LatestNews.this, listitem));
}else {
Toast.makeText(LatestNews.this, "services received Fail", Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
这是自定义适配器代码
holder.icon=(ImageView)convertView.findViewById(R.id.NewsIconID);
holder.name=(TextView) convertView.findViewById(R.id.txt_newsNameID);
holder.date=(TextView) convertView.findViewById(R.id.txt_newsDateID);
holder.id= (TextView) convertView.findViewById(R.id.txt_hiddenID);
holder.platform=(TextView) convertView.findViewById(R.id.txt_hidden2);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Latest_list services=newslist.get(position);
Picasso.with(context).load(services.getNews_icon()).into(holder.icon);
Log.d("Url",services.getNews_icon());
holder.name.setText(services.getNews_name());
holder.date.setText(services.getNews_date());
holder.id.setText(services.getNews_id());
holder.platform.setText(services.getNews_platform());
请任何人帮助我,我应该为此做些什么?
答案 0 :(得分:0)
我们在这里谈论什么样的照片?它们的尺寸很大吗?如果可以的话也尝试这个
而不是
Picasso.with(context).load(services.getNews_icon()).into(holder.icon);
尝试
Picasso.with(context).load(services.getNews_icon()).fit().into(holder.icon);