【发布时间】:2015-12-27 23:04:09
【问题描述】:
我不知道这段代码的问题在哪里?它在 Nav 标题中提供了一个空白的 imageView....
这是代码:
final View header = navigationView.getHeaderView(0);
TextView text = (TextView) header.findViewById(R.id.TxtUsernametitle);
TextView Tmail = (TextView)header.findViewById(R.id.textmail);
imageView1 = (ImageView)header.findViewById(R.id.imageView1);
String Tusern = currentUser.getUsername();
String Tmails = currentUser.getEmail();
text.setText(Tusern);
Tmail.setText(Tmails);
String usId= currentUser.getObjectId().toString();
ParseQuery<ParseObject> query = ParseQuery.getQuery("Profile");
query.whereEqualTo("userID", usId);
query.getFirstInBackground(new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (object == null) {
ParseFile fileObject = (ParseFile) object.getParseFile("picture");
fileObject
.getDataInBackground(new GetDataCallback() {
public void done(byte[] data,
ParseException e) {
if (e == null) {
// Decode the Byte[] into
// Bitmap
Bitmap bmp = BitmapFactory
.decodeByteArray(
data, 0,
data.length);
// initialize
// ImageView imageView1 = (ImageView)header.findViewById(R.id.imageView1);
// Set the Bitmap into the
// ImageView
imageView1.setImageBitmap(bmp);
} else {
}
}
});
} else {
}
}
});
我的屏幕上没有任何日志或错误...
您的帮助将不胜感激!!! 问候, 马旺
【问题讨论】:
-
你必须用样本大小压缩
bitmap。 -
我的建议是使用 ImageLoader 库...(Picasso / Universal Image Loader / Fresco / Glide)下载并显示图像到 imageview
标签: android parse-platform header imageview nav