簡體   English   中英

如何通過PHP作為中間件在android中顯示存儲在C:/ xampp / htdocs / uploads文件夾中的圖像

[英]How to display images which stored in C:/xampp/htdocs/uploads folder through PHP as middleware in android

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




?>

我不認為畢加索可以加載本地圖像; 這意味着不要從互聯網上下載它們。 https://example.com/imageurl更新:您可以: Picasso從文件系統加載圖像,但您的服務器不是您的本地文件系統。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM