毕加索(Picasso)无法将图像加载到最后两个图像视图中吗?

时间:2019-01-11 12:31:09

标签: java android picasso

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_uploaded_documents);
    frontICImageView = findViewById(R.id.frontImageView);
    backICImageView = findViewById(R.id.backImageView);
    selfieImageView = findViewById(R.id.selfieImageView);
    payslipImageView = findViewById(R.id.payslipImageView);
    String frontICURL = "https://www.example.com/image1.png"
    String backICURL = "https://www.example.com/image2.png"
    String selfieURL = "https://www.example.com/image3.png"
    String payslipURL = "https://www.example.com/image4.png"
    if(frontICURL != null) {
        if(!frontICURL.equals("false")){
            Picasso.get().load(frontICURL).into(frontICImageView);
        }
    }
    if(backICURL != null) {
        if(!backICURL.equals("false")){
            Picasso.get().load(backICURL).into(backICImageView);
        }
    }
    if(selfieURL != null) {
        if(!selfieURL.equals("false")){
            Picasso.get().load(selfieURL).placeholder(R.drawable.not_applicable).into(selfieImageView);
        }
    }
    if(payslipURL != null) {
        if(!payslipURL.equals("false")){
            Picasso.get().load(payslipURL).into(payslipImageView);
        }
    }
}

毕加索只能将图像加载到前两个图像视图中,而其他两个图像视图始终为空白(白色)。我怎样才能解决这个问题?调试了几个小时。

具有Internet权限,并且图像在浏览器中可以正常工作。

1 个答案:

答案 0 :(得分:0)

在将其与Picasso结合使用之前,请尝试解析您的网址

String payslipURL = "https://www.example.com/image1.png"
String url = Uri.parse(payslipURL)
                .buildUpon()
                .build()
                .toString();
Picasso.get().load(url).into(payslipImageView);