我見過一個關於如何在列表視圖中顯示textview和imageview的例子。這些圖像文件在可繪製文件中。在外部鏈接中顯示圖像
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null){
convertView=LayoutInflater.from(mContext).inflate(R.layout.item, null);
ItemViewCache viewCache=new ItemViewCache();
viewCache.mTextView=(TextView)convertView.findViewById(R.id.text);
viewCache.mTextView1=(TextView)convertView.findViewById(R.id.text1);
viewCache.mImageView=(ImageView)convertView.findViewById(R.id.image);
convertView.setTag(viewCache);
}
ItemViewCache cache=(ItemViewCache)convertView.getTag();
cache.mTextView.setText(texts[position]);
cache.mTextView1.setText(texts1[position]);
cache.mImageView.setImageResource(images[position]);
return convertView;
}
}
private static class ItemViewCache{
public TextView mTextView;
public TextView mTextView1;
public ImageView mImageView;
}
private String[] texts=new String[]{"one","two","three"};
private String[] texts1=new String[]{"wether","tuan","background"};
private int[] images=new int[]{R.drawable.img1,R.drawable.img2,R.drawable.img3};
但是我有什麼就是這些圖像的外部URL鏈接:
private String[] images=new String[]{"http://ia.media-imdb.com/images/M/[email protected]@._V1._SX54_CR0,0,54,74_.jpg",
"http://i.media-imdb.com/images/SF1f0a42ee1aa08d477a576fbbf7562eed/realm/feature.gif",
"http://ia.media-imdb.com/images/M/MV5BMzk3MTE5MDU5NV5BMl5BanBnXkFtZTYwMjY3NTY3._V1._SX54_CR0,0,54,74_.jpg"};
我應該使用什麼方法來顯示這些圖像?