加载图片来自URL,而不是在本地是否 [英] Loading images from URL instead if locally
问题描述
我已经成功地建立了从绘制目录(本地)加载图像成功,和我想改变它,所以它会从网络上,而不是加载图像。
我在GridView显示图像,你会我必须做我的code从网页加载它们呢?
任何帮助将是AP preciated,谢谢。
适配器:
包com.question;进口android.content.Context;
进口android.view.View;
进口android.view.ViewGroup;
进口android.widget.BaseAdapter;
进口android.widget.GridView;
进口android.widget.ImageView;公共类AdapterViewADV延伸BaseAdapter {
私人语境mContext;
公共整数[] = mThumbIds {
R.drawable.Image1,
R.drawable.Image2,
R.drawable.Image3,
R.drawable.Image4,
R.drawable.Image5,
R.drawable.Image6};
公共AdapterViewADV(上下文C){
mContext = C;
}@覆盖
公众诠释的getCount(){
返回mThumbIds.length;
}@覆盖
公共对象的getItem(INT位置){
返回mThumbIds [位置]
}@覆盖
众长getItemId(INT位置){
返回0;
}@覆盖
公共查看getView(INT位置,查看convertView,父母的ViewGroup){
ImageView的ImageView的=新ImageView的(mContext);
imageView.setImageResource(mThumbIds [位置]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(新GridView.LayoutParams(NO_SELECTION,NO_SELECTION));
返回ImageView的;
}}
下面是针对下面的例子....
<一个href=\"http://www.ethemsulan.com/2011/05/how-to-load-internet-images-in-gridview-android-sample-2.html\">http://www.ethemsulan.com/2011/05/how-to-load-internet-images-in-gridview-android-sample-2.html
<一个href=\"https://github.com/desertjim/LazyLoadingGridView\">https://github.com/desertjim/LazyLoadingGridView
<一个href=\"https://github.com/nostra13/Android-Universal-Image-Loader\">https://github.com/nostra13/Android-Universal-Image-Loader
<一个href=\"https://github.com/koush/UrlImageViewHelper\">https://github.com/koush/UrlImageViewHelper
试试这些例子,你可以得到一些想法......
I've managed to set up loading images from the drawable directory(locally) successfully, and I'm thinking of changing it so it will load the images from the web instead.
I am displaying the images in a GridView, what would I have to do to my code to load them from the web instead?
Any help would be appreciated, thanks.
Adapter:
package com.question;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class AdapterViewADV extends BaseAdapter {
private Context mContext;
public Integer[] mThumbIds = {
R.drawable.Image1,
R.drawable.Image2,
R.drawable.Image3,
R.drawable.Image4,
R.drawable.Image5,
R.drawable.Image6
};
public AdapterViewADV(Context c){
mContext = c;
}
@Override
public int getCount() {
return mThumbIds.length;
}
@Override
public Object getItem(int position) {
return mThumbIds[position];
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(mThumbIds[position]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(NO_SELECTION, NO_SELECTION));
return imageView;
}
}
Here is the below examples for that....
http://www.ethemsulan.com/2011/05/how-to-load-internet-images-in-gridview-android-sample-2.html
https://github.com/desertjim/LazyLoadingGridView
https://github.com/nostra13/Android-Universal-Image-Loader
https://github.com/koush/UrlImageViewHelper
How do I do a lazy load of images in ListView
images url are not displaying in grid
Try these examples you can get some ideas...
这篇关于加载图片来自URL,而不是在本地是否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!