【发布时间】:2013-02-27 16:27:00
【问题描述】:
我已经编写了将图像加载到 ImageView 小部件的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery);
i = (ImageView)findViewById(R.id.imageView1);
new get_image("https://www.google.com/images/srpr/logo4w.png") {
ImageView imageView1 = new ImageView(GalleryActivity.this);
ProgressDialog dialog = ProgressDialog.show(GalleryActivity.this, "", "Loading. Please wait...", true);
protected void onPreExecute(){
super.onPreExecute();
}
protected void onPostExecute(Boolean result) {
i.setImageBitmap(bitmap);
dialog.dismiss();
}
}.execute();
}
现在,我想加载几张图片。为此,我需要动态创建图像视图,但我不知道如何...
我想在 for 循环中运行我的代码:
for(int i;i<range;i++){
//LOAD SEVERAL IMAGES. READ URL FROM AN ARRAY
}
我的主要问题是在循环中动态创建多个 ImageView
【问题讨论】:
-
无法使用Android内置列表控件有什么特殊原因吗?
-
@Premsuraj:不,我可以为此使用内置小部件吗?怎么样?
-
为什么需要多个图像视图?目的是什么?您需要在列表中显示图像吗?
-
@vmerror:我想在像 instagram 应用这样的滚动查看器中加载几张图像。请以简单的方式帮助我
-
如果有要求,你需要先学习android ListView 和自定义Adapter,在adapter getView 方法中下载图片并设置为自定义xml 布局。这应该是方法。