首页 > 解决方案 > 如何通过PHP显示存储在C:/xampp/htdocs/uploads文件夹中的图像作为android中的中间件

问题描述

我从getphotos.php. 现在我想使用 Picasso 在 Android 中显示它,但它没有显示任何内容。我在 android 应用程序中成功获取了图像路径,但没有显示图像(路径类似于C:/xampp/htdocs/LBS/uploads/San-Coll.png)。

毕加索版本是com.squareup.picasso:picasso:2.5.1

安卓代码:

private void showPlacements() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(APIUrl.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create()) //Here we are using the GsonConverterFactory to directly convert json data to object
                .build();

        APIService api = retrofit.create(APIService.class);
        Call<List<Placement>> call = api.showPlacement();

        call.enqueue(new Callback<List<Placement>>() {

            @Override
            public void onResponse(Call<List<Placement>> call, Response<List<Placement>> response) {
                placementList = response.body();
                layoutManager = new LinearLayoutManager(PlacementActivity.this);
                recyclerView.setLayoutManager(layoutManager);

                PlacementAdapter recyclerViewAdapter = new PlacementAdapter(getApplicationContext(), placementList);
                recyclerView.setAdapter(recyclerViewAdapter);


            }

            @Override
            public void onFailure(Call<List<Placement>> call, Throwable t) {

            }
        });
    }

PHP代码:

<?php

require 'dbconnect.php';




                // print_r($table);die();

                $sql="SELECT image_path from photos ";

                $result = $con->query($sql);

                $rows = array();

                while($row = $result->fetch_assoc())
                {
                    $rows[] =$row;
                }   
                print json_encode($rows); 




?>

标签: javaandroidimageviewpicasso

解决方案


我不认为毕加索可以加载本地图像;这意味着不要从互联网上下载它们。像https://example.com/imageurl 更新:您可以:Picasso 从文件系统加载图像,但您的服务器不是本地文件系统。


推荐阅读