I got the following getView in listView's adapter:
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
View view = convertView;
if (view == null) {
view = LayoutInflater.from(context).inflate(R.layout.item_message, null);
}
final Message msg = getItem(position);
final AQuery aq = new AQuery(view);
aq.id(R.id.message_baloon).background(myMessage ? R.drawable.chat_message_own : R.drawable.chat_message_other);
// shared image
if (msg.getPhotos() != null && msg.getPhotos().size() != 0) {
aq.id(R.id.sent_photo).visible();
aq.image(msg.getPhotos().get(0).getUrl(), true, true, 540, R.drawable.room_details_gallery_placeholder);
aq.clicked(new View.OnClickListener() {
@Override
public void onClick(View v) {
//show fullsecreen photo
}
});
} else {
aq.id(R.id.sent_photo).gone();
}
if (msg.getText() == null || msg.getText().length() == 0) {
aq.id(R.id.message).gone();
} else {
aq.id(R.id.message).text(msg.getText());
aq.id(R.id.message).visible();
}
return view;
}
The method is actually a longer but this part contains everything related to that ImageView. So, as the title states, when scrolling really fast the ImageView, with "R.id.sent_photo", is visible for a position which doesn't have a photo and not for a fraction of a second, it remains visible (that's AndroidQuery library that I'm using).
Thank you!
I was got same problem so, i had used following methods in my custom adapter, i got solution.
Add following methods inside your ListViewItemsAdapter:
@Override
public int getCount() {
return alUpgradeTour.size();
}
@Override
public int getItemViewType(int position) {
return position;
}
@Override
public int getViewTypeCount() {
return getCount();
}
Try it, you will also get solution.
Try this, it seems that AndroidQuery library don't put placeholder image before download
if (msg.getPhotos() != null && msg.getPhotos().size() != 0) {
aq.id(R.id.sent_photo).visible();
aq.id(R.id.sent_photo).setImageResource(R.drawable.room_details_gallery_placeholder);
aq.image(msg.getPhotos().get(0).getUrl(), true, true, 540, R.drawable.room_details_gallery_placeholder);
aq.clicked(new View.OnClickListener() {
@Override
public void onClick(View v) {
//show fullsecreen photo
}
});
} else {
aq.id(R.id.sent_photo).gone();
}
The solution is not using memory cache: aq.image(msg.getPhotos().get(0).getUrl(), false , true, 540, R.drawable.room_details_gallery_placeholder);
AndroidQuery somewhere along that image function does the following
public static void async(Activity act, Context context, ImageView iv, String url, boolean memCache, boolean fileCache, int targetWidth, int fallbackId, Bitmap preset, int animation, float ratio, float anchor, Object progress, AccountHandle ah, int policy, int round, HttpHost proxy, String networkUrl){
Bitmap bm = null;
if(memCache){
bm = memGet(url, targetWidth, round);
}
if(bm != null){
iv.setTag(AQuery.TAG_URL, url);
Common.showProgress(progress, url, false);
setBmAnimate(iv, bm, preset, fallbackId, animation, ratio, anchor, AjaxStatus.MEMORY);
}else{
Bit...
So if it got a bitmap from memCache it calls setBmAnimate
private static void setBmAnimate(ImageView iv, Bitmap bm, Bitmap preset, int fallback, int animation, float ratio, float anchor, int source){
bm = filter(iv, bm, fallback);...
And filter is:
private static Bitmap filter(View iv, Bitmap bm, int fallback){
//ignore 1x1 pixels
if(bm != null && bm.getWidth() == 1 && bm.getHeight() == 1 && bm != empty){
bm = null;
}
if(bm != null){
iv.setVisibility(View.VISIBLE);
}else if(fallback == AQuery.GONE){
iv.setVisibility(View.GONE);
}else if(fallback == AQuery.INVISIBLE){
iv.setVisibility(View.INVISIBLE);
}
return bm;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.