如何通过网址,填充动态创建的ImageView asyncronously ......在Android中 [英] How to populate dynamically created imageview through urls asyncronously...In Android

查看:144
本文介绍了如何通过网址,填充动态创建的ImageView asyncronously ......在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的水平寻呼机

<一个href=\"https://github.com/ysamlan/horizontalpager/blob/master/src/com/github/ysamlan/horizontalpager/HorizontalPager.java\" rel=\"nofollow\">https://github.com/ysamlan/horizontalpager/blob/master/src/com/github/ysamlan/horizontalpager/HorizontalPager.java

要进行动态的观点,并在它使动态图像....

和使用费多尔ImageLoader的以pupulate从URL中imageviews ...
https://github.com/thest1/LazyList/blob/master/src/com/fedorvlasov/lazylist/ImageLoader.java

但我得到那个讨厌的STID图像....
这里是我的code ...

任何帮助或建议将不胜拨款

感谢名单提前

 公共类测试扩展活动{私人Horizo​​ntalPager mPager;
 ImageView的[]的形象; 字符串URL = \"http://icons-search.com/img/icons-land/IconsLandVistaStyleEmoticonsDemo.zip/IconsLandVistaStyleEmoticonsDemo-PNG-256x256-Cool.png-256x256.png\"; @覆盖
 公共无效的onCreate(最终捆绑savedInstanceState){
  super.onCreate(savedInstanceState);
  的setContentView(R.layout.testing);
  ImageLoader的ImageLoader的=新ImageLoader的(本);
  mPager =(Horizo​​ntalPager)findViewById(R.id.horizo​​ntal_pager);  图像=新ImageView的[2];
  对(INT I = 0; I&2;我++){   图片[i] =新ImageView的(getApplicationContext());
   图片[I] .setImageResource(R.drawable.logo_background);
   RelativeLayout.LayoutParams layoutParams90 =新RelativeLayout.LayoutParams(
     225,250);
   layoutParams90.leftMargin = 25;
   图片[I] .setLayoutParams(layoutParams90);
   mPager.addView(图片由[i]);  }  对(INT I = 0; I&2;我++){
   imageLoader.DisplayImage(URL,图片[I]);
  }
 }}


解决方案

当您创建的ImageView尝试通过自己的活动,而不是应用程序上下文。因此,更换此

 图片[I] =新ImageView的(getApplicationContext());

 图片[I] =新ImageView的(本);

I am using horizontal pager

https://github.com/ysamlan/horizontalpager/blob/master/src/com/github/ysamlan/horizontalpager/HorizontalPager.java

to make dynamic views,and making dynamic images in it....

And using fedor imageloader to pupulate imageviews from urls... https://github.com/thest1/LazyList/blob/master/src/com/fedorvlasov/lazylist/ImageLoader.java

but i am getting that annoying stid image.... here is my code...

Any help or suggestion will be highly appropriated

Thanx in advance

public class testing extends Activity {

private HorizontalPager mPager;
 ImageView[] image;

 String url = "http://icons-search.com/img/icons-land/IconsLandVistaStyleEmoticonsDemo.zip/IconsLandVistaStyleEmoticonsDemo-PNG-256x256-Cool.png-256x256.png";

 @Override
 public void onCreate(final Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.testing);
  ImageLoader imageLoader = new ImageLoader(this);
  mPager = (HorizontalPager) findViewById(R.id.horizontal_pager);

  image = new ImageView[2];
  for (int i = 0; i < 2; i++) {

   image[i] = new ImageView(getApplicationContext());
   image[i].setImageResource(R.drawable.logo_background);
   RelativeLayout.LayoutParams layoutParams90 = new RelativeLayout.LayoutParams(
     225, 250);
   layoutParams90.leftMargin = 25;
   image[i].setLayoutParams(layoutParams90);
   mPager.addView(image[i]);

  }

  for (int i = 0; i < 2; i++) {
   imageLoader.DisplayImage(url, image[i]);
  }
 }

}

解决方案

When you create ImageView try to pass your Activity instead of Application context. So replace this

image[i] = new ImageView(getApplicationContext());

with this

image[i] = new ImageView(this);

这篇关于如何通过网址,填充动态创建的ImageView asyncronously ......在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆