long list show incorrect list items on custom listview with images from android universal image loader
See original GitHub issueI tried to display a custom list view that display custom list items with image and text lines. I want two type of list items (left align and right alined, just as message thread). I have used Android-Universal-Image-Loader to load web images. bt when i load the list, it load wrong list items time to time. when i scroll fast it changed the alignment of list items time to time.
here u can see the one user (a girl profile picture) reply not in a right aligned all the time
here’s my coding,
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.drawable.social_person)
.showStubImage(R.drawable.ic_launcher)
.showImageOnFail(R.drawable.ic_launcher)
.showStubImage(R.drawable.social_person)
.cacheInMemory(true)
.cacheOnDisc(true)
.displayer(new RoundedBitmapDisplayer(20))
.build();
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder vh = null;
threadMessageObj = threadMessagesList.get(position);
mSenderId = threadMessageObj.getSenderID();
if(convertView == null){
vh = new ViewHolder();
if(threadMessageObj.getSenderID().equals(mLoggedUserID)){
convertView = inflater.inflate(R.layout.thread_message_row_right, null);
vh.messageTxt = (TextView) convertView.findViewById(R.id.message_body_r);
vh.dateTimeView = (TextView) convertView.findViewById(R.id.message_datetime_r);
vh.imageView = (ImageView) convertView.findViewById(R.id.receipient_image);
}else{
convertView = inflater.inflate(R.layout.thread_message_row_left, null);
vh.messageTxt = (TextView) convertView.findViewById(R.id.message_body);
vh.dateTimeView = (TextView) convertView.findViewById(R.id.message_datetime);
vh.imageView = (ImageView) convertView.findViewById(R.id.sender_image);
}
convertView.setTag(vh);
}else{
vh = (ViewHolder) convertView.getTag();
}
String messageText = null;
String messageTimeText = null;
String messageDateText;
String mSenderImage = null;
mSenderImage = threadMessageObj.getSenderImage();
imageUri = ConstantValues.API_IP_NEW + threadMessageObj.getSenderImage(); // from Web
if( threadMessageObj.getMessageTime() != null){
messageTimeText = threadMessageObj.getMessageTime().trim();
}
if( threadMessageObj.getMessageBody() != null){
messageText = threadMessageObj.getMessageBody().trim();
}
String DateTimeArray[] = messageTimeText.split("\\s+");
String dateTxt = DateTimeArray[0];
String timeTxt = DateTimeArray[1];
String processedTime = vip.getProcessedDate(dateTxt) + " " + vip.getProcessedTime(timeTxt);
if(messageText != null){
vh.messageTxt.setText(messageText);
}else{
vh.messageTxt.setText("");
}
if(messageTimeText != null){
vh.dateTimeView.setText(processedTime);
}
String[] imageUrls = new String[imageURIList.size()];
imageUrls = imageURIList.toArray(imageUrls);
if(mSenderImage != null){
imageLoader.displayImage(imageUri, vh.imageView, options, animateFirstListener);
}else{
imageLoader.displayImage(null, vh.imageView);
}
return convertView;
}// end getView
how to get solved this issue?
Issue Analytics
- State:
- Created 10 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
android - Universal Image Loader Showing Wrong Images for ...
I am a beginner in android coding...And I stumbled On this problem where UIL is showing wrong images for wrong items in a...
Read more >ListView with Images and Text [Scroll With NO Lag] - YouTube
Android Beginner Tutorial #10 - ListView with Images and Text [Scroll With NO Lag]By the end of this video you will know how...
Read more >Android ListView with Custom Adapter Example Tutorial
In this tutorial we'll build an application that consists of list of rows displaying text descriptions and an info icon. Clicking the row...
Read more >Customizing ListView Cell Appearance - Xamarin
Forms ListView class is used to present scrollable lists, which can be customized through the use of ViewCell elements.
Read more >Android ListView Universal Image Loader Changes ... - iTecNote
When I scroll through the list, all the profile pictures load fine and work great. But as I scroll, the status photos do...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should check your holder here
If the holder holds the view you want, you can reuse it. If not you should instantiate a new one.
Hope this could help 😃
Eventually you can ask for help on StackOverFlow - http://stackoverflow.com/