如何通过PHP作为Android中间件显示存储在C:/ xampp / htdocs / uploads文件夹中的图像

时间:2019-04-16 21:25:03

标签: java android imageview picasso

我从getphotos.php获取完整的图像路径(JSON格式列表)。现在,我想在Android中使用Picasso展示它,但是它什么也没显示。我在Android应用程序中成功获取了图像路径,但未显示图像(路径类似于C:/xampp/htdocs/LBS/uploads/San-Coll.png)。

毕加索的版本为com.squareup.picasso:picasso:2.5.1

Android代码:

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); 




?>

1 个答案:

答案 0 :(得分:0)

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