0

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.

ely87
  • 126
  • 5
  • Please, refer to this link: [LINK TO SOLVE ALL YOUR PROBLEMS][1] [1]: http://stackoverflow.com/questions/13011302/lazy-loading-images-on-listview-not-getting-refreshed/13074049#13074049 – ely87 Oct 25 '12 at 17:46
  • Struggling with exact same senario..Any luck? – teekib Dec 20 '12 at 14:48

0 Answers0