简体   繁体   English

Picasso 未在 ImageView 中加载图像

[英]Picasso not loading images in ImageView

I wanted to load images from Url into a simple Imageview using Picasso.我想使用 Picasso 将 Url 中的图像加载到一个简单的 Imageview 中。 But unfortunately I am facing some issue.但不幸的是,我正面临一些问题。 I have included the logs below and the relevant code.我已经包含了下面的日志和相关代码。 I have given Internet permission and using the latest build of Picasso.我已授予 Internet 许可并使用 Picasso 的最新版本。

enter image description here在此处输入图片说明

MainActivity.java主活动.java

package com.example.picassotest;

import androidx.appcompat.app.AppCompatActivity;

import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

    ImageView imgView;
    TextView txtView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        imgView = findViewById(R.id.img_view);
        txtView = findViewById(R.id.txtview);
        Picasso.get().setLoggingEnabled(true);
        Picasso.get().load("https://images.unsplash.com/photo-1500100586562-f75ff6540087?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=3589&q=80").into(imgView);
    }
}

activity_main.xml活动_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/img_view"
        app:layout_constraintStart_toStartOf="@id/img_view"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher_round"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtview"
        app:layout_constraintTop_toBottomOf="@id/img_view"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:text="Hey"
        />


</androidx.constraintlayout.widget.ConstraintLayout>

Logs日志

Link: https://pastebin.com/820tP9Jd链接: https : //pastebin.com/820tP9Jd

在清单中使用它

android:usesCleartextTraffic="true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM