我的适配器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);
}
答案 0 :(得分:0)
您需要在json响应中拥有图像的URL或路径。你不能给<ImageName>.png
作为输入。