I was working on a piece of code where I have a listview and a custom element(item) with: relativelayout, textview,imageview,etc.
public View getView(int position, View convertView, ViewGroup parent) {
WindowManager wm = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
int widthScreen = display.getWidth();
int heightScreen = display.getHeight();
if (convertView == null) {
convertView = inflater
.inflate(R.layout.program_specific_item, null);
viewHolder = new ProgramInitialViewHolder();
viewHolder.photo = (ImageView) convertView
.findViewById(R.id.image_photo);
.findViewById(R.id.start_time);
viewHolder.endTime = (TextView) convertView
.findViewById(R.id.end_time);
viewHolder.type.setFocusable(false);
viewHolder.endTime.setFocusable(false);
viewHolder.startTime.setFocusable(false);
convertView.setTag(viewHolder);
} else {
viewHolder = (ProgramInitialViewHolder) convertView.getTag();
}
final Event element = schedule.get(position);
try {
imageLoader.DisplayImage(schedule.get(position).getPicture(),
viewHolder.photo);
} catch (Exception g) {
g.printStackTrace();
} return convertView; } -END-
I implemented viewHolder pattern and I am trying to include Lazy Loading code to improve performance. It seems that every time I scroll up/down my images get recycled and the lazy loading & the auto displaying images (refreshing) is not working: I need to scroll in order to get the images visually (even though in logic they are already there).
So, should I stop using this viewHolder pattern or should I do something else in order to successfully create my listview & lazy loading ?
PS: I already checked on SO all lazy loading&viewholder pattern's links.