0
我得到了這個應用程序,它將用戶的Facebook ID記錄在MySQL表中,現在我試圖獲取此ID並在ListView上顯示用戶的個人資料圖片,但我不知道我做錯了什麼。將Facebook個人資料圖片設置爲ListView中的ImageView
我定製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;
}
}
的logcat:http://pastebin.com/kmLXKvZJ
此外,這是一個選項卡中。它在Tab 2中,當應用程序從Tab 1開始,當我點擊Tab 2(查看此列表)時,加載需要幾秒鐘,有什麼我可以做的更快地加載它?