제 문제는 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;
}
내있는 getIcon()를 정말 "Uri.parse 쓴 이유 setImageUri –
와 함께 잘 작동하지 않는 문자열 반환 (o.getIcon을()) " – njzk2