我试图使用脸谱图api url和用户名来显示Facebook用户的个人资料照片。
String Name = jsonObjectlike.getString("name");
String UserIds = jsonObjectlike.getString("id");
URL url = new URL("https://graph.facebook.com/" + listid + "/picture?type=small");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
HashMap<String, String> contact = new HashMap<>();
contact.put("picid", bmp);
contact.put("name", Name);
contactList.add(contact);
这里是在listview中显示的simpleAdapter:
SimpleAdapter adapter = new SimpleAdapter(MainActivity.this, contactList,R.layout.activity_listview, new String[]{"picid", "name"}, new int[]{R.id.imageView1,R.id.name});
simpleList.setAdapter(adapter);
我在listView中成功显示了名称,但图片未显示,
答案 0 :(得分:0)
String Name = jsonObjectlike.getString("name");
String UserIds = jsonObjectlike.getString("id");
URL url = new URL("https://graph.facebook.com/" + listid + "/picture?type=small");
HashMap<String, String> contact = new HashMap<>();
//contact.put("picid", bmp);<- use Image URL not bitmap
contact.put("picid", url);
contact.put("name", Name);
contactList.add(contact);
在你的SimpleAdapter句柄中是picid并在带有Glide库的Imageview中显示。
答案 1 :(得分:0)
ImageView user_picture;
userpicture=(ImageView)findViewById(R.id.userpicture);
URL img_value = null;
img_value = new URL("http://graph.facebook.com/"+id+"/picture?type=large");
Bitmap mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());
userpicture.setImageBitmap(mIcon1);
答案 2 :(得分:0)
我通过创建包含已解码图像网址和文本的自定义listView适配器来修复自己。它对我来说很完美。