1

제 문제는 URL에서 이미지를 가져 와서 이미지 뷰로 설정하는 사용자 정의 배열 어댑터를 구현 한 것입니다. 일종의, 작동합니다. 경우에 따라 일부 이미지가 표시되지 않는 경우도 있습니다. 때로는 하나의 이미지 일 뿐이며 때로는 3 단계이며 명백한 순서가 아닙니다. 합리적으로 일관된 것만이 내 arraylist에서 이미지 번호 3 인 것으로 보입니다.때때로 내 목록보기의 아이콘이 표시되지 않습니다

내 사용자 정의 어댑터 :

public CustomAdapter(Context context, int textViewResourceId, List items) 
{ 
     super(context, textViewResourceId, items); 
     this.items = items; 
} 

@Override 
public View getView(int position, View convertView, ViewGroup parent) 
{ 
    View v = convertView; 
    if (v == null) 
    { 
     LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     v = vi.inflate(R.layout.list_item, parent, false); 
    } 
    Object o = items.get(position); 
    if (o != null) 
    { 
      TextView textView = (TextView) v.findViewById(R.id.listItem); 
      ImageView imageView = (ImageView) v.findViewById(R.id.icon); 

      if (textView != null) 
      { 
       textView.setText(o.toString()); 
      } 
      if (imageView != null) 
      { 
       if (o instanceof XmlGuide) 
       { 
        try 
        { 
         imageView.setImageBitmap(downloadIcon(((XmlGuide) o).getIcon())); 
        } 
        catch(Exception e) 
        { 
         e.printStackTrace(); 
        } 
       } 
      } 
    } 
    return v; 
} 

private Bitmap downloadIcon(String uri) throws Exception 
{ 
    URL url = new URL(uri); 
    InputStream stream = url.openStream(); 
    Bitmap icon = BitmapFactory.decodeStream(stream); 
    stream.close(); 
    return icon; 
} 

답변

0

마침내 문제가 발생했습니다. 문제는 Android < 2.3이 jpg 이미지를 잘 처리하지 못한다는 것입니다. 대부분의 경우이 문제를 해결할 수있는 수정 사항이 있지만 전부는 아닙니다.

당신은 여기에 대한 자세한 내용을보실 수 있습니다 : http://code.google.com/p/android/issues/detail?id=6066

0

은 당신의 getView 동안 차단 네트워크 부분은이 권유하지 않는 한.

사용

setImageUri(Uri.parse(o.getIcon()); 

확실히 낫다.

+0

내있는 getIcon()를 정말 "Uri.parse 쓴 이유 setImageUri –

+0

와 함께 잘 작동하지 않는 문자열 반환 (o.getIcon을()) " – njzk2