滑动占位符不显示图像

时间:2018-06-14 09:52:08

标签: android android-layout android-glide

android滑翔不显示获取的图像。它停留在默认图像。我使用滑动版本4.7.1这里是我的代码吼叫

mStorageRef = FirebaseStorage.getInstance()。getReference();

 mAuthUser = FirebaseAuth.getInstance();
 firebaseFirestore = FirebaseFirestore.getInstance();
 userIDM = mAuthUser.getCurrentUser().getUid();

 //getting data from firebaseFireStore
 firebaseFirestore.collection("Users").document(userIDM).get().addOnCompleteListener(new
 OnCompleteListener<DocumentSnapshot>() {
     @Override
     public void onComplete(@NonNull Task<DocumentSnapshot> task) {
         if (task.isSuccessful()){

             Toast.makeText(SetupActivity.this, "success", Toast.LENGTH_LONG).show();

             if (task.getResult().exists()){

                 Toast.makeText(SetupActivity.this, "user data exist", Toast.LENGTH_LONG).show();
                  String name = task.getResult().getString("name");
                  String image = task.getResult().getString("image");

                 RequestOptions placeHolder = new RequestOptions();
                 placeHolder.placeholder(R.mipmap.setup_user);

                 userName.setText(name);
                 Glide
                         .with(SetupActivity.this)
                         .setDefaultRequestOptions(placeHolder)
                         .load(image)
                         .into(userImage);

             }else {
                 Toast.makeText(SetupActivity.this, "user data dose'nt exist", Toast.LENGTH_LONG).show();

             }

         }else {

             String errorM = task.getException().getMessage();
             Toast.makeText(SetupActivity.this,"error"+errorM, Toast.LENGTH_LONG).show();

         }
     }
 });

4 个答案:

答案 0 :(得分:2)

制作一个像这样的空课

import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;

// new since Glide v4
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {}

现在使用Glide:

GlideApp.with(SetupActivity.this)
.load(image)
.placeholder(R.mipmap.setup_user)
.into(userImage);

答案 1 :(得分:0)

  RequestOptions placeholderRequest = new RequestOptions();
                        placeholderRequest.placeholder(drawable img you want);

                        Glide.with(SetupActivity.this).setDefaultRequestOptions(placeholderRequest).load(ur variable).into(ur vraiable);

答案 2 :(得分:0)

滑行添加 .placeholder(您的图片) 它有效

答案 3 :(得分:-1)

降级Glide版对我有用。你可以尝试一下。