私の問題は、URLから画像をフェッチして画像ビューに設定するカスタムarrayadapterを実装したことです。それは、ある種、機能します。一部の画像が表示されない場合があります。1つの画像だけの場合もあれば、3つの画像であり、明確な順序がない場合もあります。合理的に一貫しているのは、配列リストの画像番号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;
}