I have ViewPager which in I adding some views programmatically.
Each page has imageview and textviews.
All textviews setted fine but image display only one, I mean there is only one image only in first item of viewPager, the rest doesn't show images
private void setValues(){
final LayoutInflater li = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int size = MyApplication.getInstance().getEntityList().size();
AQuery aq = new AQuery(mActivity);
for (int i=0;i<size;i++){
Entity entity = MyApplication.getInstance().getEntityList().get(i);
View v = li.inflate (R.layout.product_main, null);
final ImageView img = (ImageView)v.findViewById(R.id.immage);
aq.id(R.id.image).image(entity.getMobile_pic(), true, true, mActivity.getCurrentDeviceDisplayMatrics().widthPixels, 0, new BitmapAjaxCallback(){
@Override
public void callback(String url, ImageView iv, Bitmap loadedImage, AjaxStatus status){
iv.setImageBitmap(Bitmap.createBitmap(loadedImage, 0, loadedImage.getHeight()/2, loadedImage.getWidth(), loadedImage.getHeight()/2));
}
});
((TextView) v.findViewById(R.id.name)).setText(entity.getTitle());
((TextView)v.findViewById(R.id.description)).setText(entity.getDescription());
pagerAdapter.addView(v);
pagerAdapter.notifyDataSetChanged();
}
What is wrong here and why other images don't show?
Just do this
aq = new Aquery(img)
not pass activity.
That's it.