如何通过网址,填充动态创建的ImageView asyncronously ......在Android中 [英] How to populate dynamically created imageview through urls asyncronously...In 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 ...
任何帮助或建议将不胜拨款
感谢名单提前
公共类测试扩展活动{私人HorizontalPager 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 =(HorizontalPager)findViewById(R.id.horizontal_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
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屋!