无法解决方法' getUrl()'

时间:2017-11-13 00:48:16

标签: android android-imageview

目前我收到此错误消息"无法解析方法' getUrl() "。你们知道我为什么会收到这个错误吗?

以下是代码:

public View getView(int position, View convertView, ViewGroup parent) {
    ImageView image = (ImageView) convertView.findViewById(R.id.imageView);
    if (convertView == null) {
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(700,1200));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(4,4,4,4);
        /**
         * Using picasso to load the images.
         */
        Picasso.with(mContext).load("http://image.tmdb.org/t/p/w500/" + movieItemLists.get(position).getUrl())
                .error(R.drawable.ic_error_placeholder)
                .placeholder(R.drawable.ic_image_1)
                .into(image);
    } else {
        imageView = (ImageView) convertView;
    }
        return imageView;
}

1 个答案:

答案 0 :(得分:0)

确保内部类中有getUrl方法。

Sample

public class YouClass{

public List<MovieItem> movieItemList;

private class MovieItem {
    private String url;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
}