我不知道这段代码的问题在哪里?它在导航标题中给出一个空白的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 {
}
}
});
我的屏幕上没有任何日志或错误。。。
我们将感谢您的帮助!!!当做Marwan
https://github.com/facebook/fresco
https://github.com/bumptech/glide
http://square.github.io/picasso/
https://github.com/koush/ion
https://github.com/nostra13/Android-Universal-Image-Loader
只需从parse下载图像url,然后将url传递给任何一个库,并为该库提供imageView引用。
我的建议是用"解析"/"滑动"来表示图像。"ion"表示您可以下载的最大文件类型(video/zip/txt)。
将此代码放在侧的object==null处
ParseFile image = (ParseFile) object.get("picture");
// now u want to use picaso library for image loaded in image view like
Picasso.with(getApplicationContext()).load(image.getUrl()).placeholder(R.drawable.ic_launcher).fit()
.into(imageView);
并删除旧代码。