我的图像没有在json volley方法的图像视图中加载

时间:2018-02-17 11:56:06

标签: android json imageview android-volley

我的适配器file.java我使用JSON排球方法。图像是不是加载图像视图如何解决这个问题?

Jason图片格式;

"image":[  
   "151660038947843.png",
   "151660038916249.png"
],

MyAdapter.java

public void onBindViewHolder(MyViewHolder holder, int position) 
{
    final Hostel hostel = hostelList.get(position);

    holder.name.setText(hostel.getName());
    holder.mobile1.setText( hostel.getMobile1() );
    holder.mobile2.setText( hostel.getMobile2() );
    holder.address.setText( hostel.getAddress() );
    holder.place.setText( hostel.getPlace() );

    Glide.with(mContext).load(hostel.getImage()).into(holder.image);
}

MyActivity.java

if(!(1 <= distance)){
    jsonName = jsonObject.getString("pname");                            
    jsonMobile1 = jsonObject.getString("price");
    jsonMobile2=jsonObject.getString( "discount" );
    jsonAddress=jsonObject.getString("pdescription");
    jsonArea=jsonObject.getString( "area" );                             
    JSONArray jsonImage = jsonObject.getJSONArray("image");
    jsonPhoto = jsonImage.getString(0);
    Hostel hostel=new Hostel(jsonPhoto, jsonName,jsonMobile1,jsonMobile2,jsonAddress,jsonArea );
    hostelList.add(hostel);
}

1 个答案:

答案 0 :(得分:0)

您需要在json响应中拥有图像的URL或路径。你不能给<ImageName>.png作为输入。