2014-09-11 72 views
0

我打電話UIL的displayImage方法,但它不接受圖像URI加載GridView的圖像。這是我的代碼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; 
    } 

任何幫助,請?

回答

1

您必須使用「繪製://」 +標識的繪製資源的

例子:

ImageLoader.getInstance().displayImage("drawable://" + R.drawable.icon_teste,holder.participantImage); 

如果你想通過它的名稱,而不是ID來獲取你繪製可以得到它的使用這種識別碼:

int id = getContext().getResources().getIdentifier(ICON_NAME, "drawable", getContext().getPackageName()); 
+0

'將String.valueOf( 「繪製://」 +圖像標識[位置])'工作!謝謝 :) – 2014-09-11 09:06:12

2

檢查影像字符串應該從readme

String imageUri = "assets://image.png"; // from assets 
String imageUri = "drawable://" + R.drawable.image; // from drawables (only images, non-9patch) 
相關問題