Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 毕加索正在加载URL,但未显示任何图片_Java_Android_Picasso - Fatal编程技术网

Java 毕加索正在加载URL,但未显示任何图片

Java 毕加索正在加载URL,但未显示任何图片,java,android,picasso,Java,Android,Picasso,到目前为止,我遇到了一个最奇怪的问题。我正在创建一个应用程序,通过不同的活动发送有关书籍和作者的信息。我将在intents的帮助下发送它们。我的问题在作者部分。我正在发送姓名、年龄和照片。姓名和年龄已成功发送,据我所知,使用调试器,图像也已成功发送。然而,毕加索拒绝将其加载到ImageView中。没有显示错误,我也不知道发生了什么。下面是一些代码 此函数用于重置我的数据库中的信息: public void resetAuthor() { SQLiteDatabase db

到目前为止,我遇到了一个最奇怪的问题。我正在创建一个应用程序,通过不同的活动发送有关书籍和作者的信息。我将在intents的帮助下发送它们。我的问题在作者部分。我正在发送姓名、年龄和照片。姓名和年龄已成功发送,据我所知,使用调试器,图像也已成功发送。然而,毕加索拒绝将其加载到ImageView中。没有显示错误,我也不知道发生了什么。下面是一些代码

此函数用于重置我的数据库中的信息:

public void resetAuthor()
    {
        SQLiteDatabase db = this.getWritableDatabase();
        db.execSQL("DELETE FROM " + TABLE_NAME_AUTHORS);
        db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + TABLE_NAME_AUTHORS + "'");

        addBegginingInfoAuthor("J.K.Rowling", 54, "https://www.biographyonline.net/wp-content/uploads/2014/05/jk-rowling4.jpg");
        addBegginingInfoAuthor("J.R.R. Tolken", 81, "https://www.biography.com/.image/t_share/MTE5NTU2MzE2Mzg4MzYxNzM5/jrr-tolkien-9508428-1-402.jpg");
        addBegginingInfoAuthor("Arthur Conan Doyle", 71, "https://upload.wikimedia.org/wikipedia/commons/b/bd/Arthur_Conan_Doyle_by_Walter_Benington%2C_1914.png");
    }
AuthorAdapter类。这是my recycler视图的适配器,该视图显示作者的详细信息。这也是我开始打算转移到其他活动的地方:

@Override
    public void onBindViewHolder(@NonNull AuthorsViewHolder holder, int position) {
        if (!mCursor.moveToPosition(position))
        {
            return;
        }

        final int author_id = mCursor.getInt(mCursor.getColumnIndex(DatabaseHelper.AUTHORS_COL_1));
        final String name = mCursor.getString(mCursor.getColumnIndex(DatabaseHelper.AUTHORS_COL_2));
        final String age = mCursor.getString(mCursor.getColumnIndex(DatabaseHelper.AUTHORS_COL_3));
        final String image = mCursor.getString(mCursor.getColumnIndex(DatabaseHelper.AUTHORS_COL_4));

        holder.authorIndex.setText(String.valueOf(author_id));
        holder.authorName.setText(name);
        holder.authorAge.setText(String.valueOf(age));
        holder.authorName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(v.getContext(), displayBooksFromAuthor.class);
                intent.putExtra("Author_id", author_id);
                intent.putExtra("Author_name", name);
                intent.putExtra("Author_age", age);
                intent.putExtra("Author_image", image);
                mContext.startActivity(intent);
            }
        });
    }
最后是我的DisplayAuthorDetails类,它从intent接收数据并显示:

int author_id = intent.getIntExtra("Author_id", 0);
        String author_name = intent.getStringExtra("Author_name");
        String author_age = intent.getStringExtra("Author_age");
        String author_picture = intent.getStringExtra("Author_image");

        et_name.setText(author_name);
        et_age.setText(author_age);
        et_id.setText(String.valueOf(author_id));
        Picasso.get().load(author_picture).into(author_image);
我在清单文件中有库依赖项和两个权限

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

经过几个小时的尝试,我终于发现要解决这个问题,我只需在emulator上重新安装应用程序。

经过几个小时的尝试,我终于发现要解决这个问题,我只需在emulator上重新安装应用程序。

检查您的文件大小和文件格式。共享DatabaseHelper的一些详细信息并进行交叉检查DisplayAuthorDetails author\u图片是否为您的图像url我编辑了问题并添加了DatabaseHelper类。我还检查了author_picture是否是URL-它是。您可以将
setlogginenabled(true)
添加到毕加索生成器中。此外,请验证是否已将作者图像正确设置为imageview。logger afetr设置setLoggingEnabled(true)中没有任何异常。我还验证了
author\u image
是ImageView的set属性检查您的文件大小和文件格式。共享DatabaseHelper的一些详细信息并交叉检查DisplayAuthorDetails author\u图片是否为您的图像url我编辑了问题并添加了DatabaseHelper类。我还检查了author_picture是否是URL-它是。您可以将
setlogginenabled(true)
添加到毕加索生成器中。此外,请验证是否已将作者图像正确设置为imageview。logger afetr设置setLoggingEnabled(true)中没有任何异常。我还验证了
author\u image
是ImageView的set属性
public class DatabaseHelper extends SQLiteOpenHelper {

    public static final String DATABASE_NAME = "Books and Authors.db";
    public static final String TABLE_NAME_AUTHORS = "Authors_table";
    public static final String AUTHORS_COL_1 = "Author_ID";
    public static final String AUTHORS_COL_2 = "Name";
    public static final String AUTHORS_COL_3 = "Age";
    public static final String AUTHORS_COL_4 = "Author_picture";
    public static final String TABLE_NAME_BOOKS = "Books_table";
    public static final String BOOKS_COL_1 = "Book_ID";
    public static final String BOOKS_COL_2 = "Author_Foreign";
    public static final String BOOKS_COL_3 = "Title";
    public static final String BOOKS_COL_4 = "Price";


    public DatabaseHelper(Context context) {

        super(context, DATABASE_NAME, null, 2);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL("create table " + TABLE_NAME_BOOKS + " (Book_ID INTEGER PRIMARY KEY AUTOINCREMENT, Title TEXT," + "Author_Foreign INT," + "Price TEXT)");
        db.execSQL("create table " + TABLE_NAME_AUTHORS + " (Author_ID INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT," + "Age INTEGER," + "Author_picture TEXT)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_AUTHORS);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_BOOKS);
        onCreate(db);
    }

    public boolean insertDataBooks(String title, float price) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(BOOKS_COL_3, title);
        contentValues.put(BOOKS_COL_4, price);


        long result = db.insert(TABLE_NAME_BOOKS, null, contentValues);


        if (result == 1) {
            return false;
        } else {
            return true;
        }
    }

    public boolean insertDataAuthors(String name, int age) {
        SQLiteDatabase mydb = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(AUTHORS_COL_2, name);
        contentValues.put(AUTHORS_COL_3, age);

        long result = mydb.insert(TABLE_NAME_AUTHORS, null, contentValues);

        if (result == 1) {
            return false;
        } else {
            return true;
        }
    }

    public boolean addBegginingInfo(int foreign_author_id, String title, double price) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(BOOKS_COL_2, foreign_author_id);
        contentValues.put(BOOKS_COL_3, title);
        contentValues.put(BOOKS_COL_4, price);

        long result = db.insert(TABLE_NAME_BOOKS, null, contentValues);

        if (result == 1) {
            return false;
        } else {
            return true;
        }
    }

    public boolean addBegginingInfoAuthor(String name, int age, String image)
    {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(AUTHORS_COL_2, name);
        contentValues.put(AUTHORS_COL_3, age);
        contentValues.put(AUTHORS_COL_4, image);

        long result = db.insert(TABLE_NAME_AUTHORS, null, contentValues);

        if (result == 1) {
            return false;
        } else {
            return true;
        }
    }

    public Integer deleteBook(String index) {
        SQLiteDatabase db = this.getWritableDatabase();
        return db.delete(TABLE_NAME_BOOKS, "Book_ID = ?", new String[]{index});
    }

    public Integer deleteAuthor(String authorIndex) {
        SQLiteDatabase db = this.getWritableDatabase();
        return db.delete(TABLE_NAME_AUTHORS, "Author_ID = ?", new String[]{authorIndex});
    }

    public void resetBookTable() {
        SQLiteDatabase db = this.getWritableDatabase();
        db.execSQL("DELETE FROM " + TABLE_NAME_BOOKS);
        db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + TABLE_NAME_BOOKS + "'");

        addBegginingInfo(1, "Harry Potter", 9.99);
        addBegginingInfo(1, "Fantastic Beasts", 14.99);
        addBegginingInfo(2, "Lord of the Rings", 8.99);
        addBegginingInfo(2, "The Hobbit", 12.99);
        addBegginingInfo(3, "Sherlock Holmes", 6.99);
        addBegginingInfo(3, "Valley of Fear", 7.99);


    }

    public void resetAuthor()
    {
        SQLiteDatabase db = this.getWritableDatabase();
        db.execSQL("DELETE FROM " + TABLE_NAME_AUTHORS);
        db.execSQL("DELETE FROM SQLITE_SEQUENCE WHERE NAME = '" + TABLE_NAME_AUTHORS + "'");

        addBegginingInfoAuthor("J.K.Rowling", 54, "https://www.biographyonline.net/wp-content/uploads/2014/05/jk-rowling4.jpg");
        addBegginingInfoAuthor("J.R.R. Tolken", 81, "https://www.biography.com/.image/t_share/MTE5NTU2MzE2Mzg4MzYxNzM5/jrr-tolkien-9508428-1-402.jpg");
        addBegginingInfoAuthor("Arthur Conan Doyle", 71, "https://upload.wikimedia.org/wikipedia/commons/b/bd/Arthur_Conan_Doyle_by_Walter_Benington%2C_1914.png");
    }
}