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

问题描述 投票:0回答:1

我从getphotos.php获得完整的图像路径(以JSON格式列出)。现在我想使用Picasso在Android中显示它,但它没有显示任何内容。我在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); 




?>
java android imageview picasso
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.