我得到了这个在 MySQL 表中记录用户 Facebook ID 的应用程序,现在我正在尝试获取此 ID 并在 ListView 上显示用户的个人资料图片,但我不知道我做错了什么。
我的自定义 ArrayAdapter:
public class VisualAdapter extends ArrayAdapter<String> {
private final Context contexto;
private final String[] comics, username, userid;
URL img_url = null;
Bitmap bm;
public VisualAdapter(Context contexto, String[] comics, String[] username,
String[] userid) {
super(contexto, R.layout.exibeimg, comics);
this.contexto = contexto;
this.comics = comics;
this.username = username;
this.userid = userid;
}
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
LayoutInflater inflater = (LayoutInflater) contexto
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.exibeimg, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.tvTitleImage);
ImageView imageView = (ImageView) rowView.findViewById(R.id.ivImageVisual);
ImageView ivUser = (ImageView) rowView.findViewById(R.id.ivUser);
TextView tvUser = (TextView) rowView.findViewById(R.id.tvUserNAME);
textView.setText(comics[position]);
tvUser.setText(username[position]);
try {
img_url = new URL("http://graph.facebook.com/"+userid+"/picture?type=thumbnail");
bm = BitmapFactory.decodeStream(img_url.openConnection().getInputStream());
ivUser.setImageBitmap(bm);
}
catch (Exception e) {
e.printStackTrace();
}
return rowView;
}
}
日志猫: http ://pastebin.com/kmLXKvZJ
此外,这是在选项卡内。它在选项卡 2 中,当我单击选项卡 2(查看此列表)时,当应用程序从选项卡 1 启动时,加载需要几秒钟,我可以做些什么来更快地加载它?