我正在调用UIL的displayImage
方法,但它不接受图片URI。这是我的getView
代码。我收到了错误:
UnsupportedOperationException: UIL doesn't support scheme(protocol) by default [2130837504]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.grid_view_card_layout, parent, false);
holder = new ViewHolder();
holder.participantName = (TextView) convertView.findViewById(R.id.grid_model_name);
holder.participantCountry = (TextView) convertView.findViewById(R.id.grid_country_name);
holder.participantImage = (ImageView) convertView.findViewById(R.id.grid_model_image);
holder.progressBar = (ProgressBar) convertView.findViewById(R.id.progress);
convertView.setTag(holder);
} else {
holder=(ViewHolder)convertView.getTag();
}
applyTypeFace(convertView);
holder.participantName.setText(ParticipantName[position]);
holder.participantCountry.setText(ParticipantCountry[position]);
//holder.participantImage.setImageResource(ImageId[position]);
//Here lies the problem
ImageLoader.getInstance()
.displayImage(String.valueOf(ImageId[position]), holder.participantImage);
return convertView;
}
请帮忙吗?
答案 0 :(得分:2)
检查您的图片字符串,它应该来自readme
String imageUri = "assets://image.png"; // from assets
String imageUri = "drawable://" + R.drawable.image; // from drawables (only images, non-9patch)
答案 1 :(得分:1)
您必须使用“drawable://”+可绘制资源的ID
示例:
ImageLoader.getInstance().displayImage("drawable://" + R.drawable.icon_teste,holder.participantImage);
如果你想通过它的名字而不是id来获取drawable,你可以使用它来获取它的标识符:
int id = getContext().getResources().getIdentifier(ICON_NAME, "drawable", getContext().getPackageName());