Friday, April 1, 2011

[android-developers] Re: Inflate alloc a new View or reuse it

Yes it works!

On 1 Apr, 10:47, Kostya Vasilyev <kmans...@gmail.com> wrote:
> So, is it working now?
> 01.04.2011 12:28 пользователь "pedr0" <pulsarpie...@gmail.com> написал:
>
>
>
>
>
>
>
> > I am so sorry for the mistake, problem happen during THIS PIECE OF
> > CODE
>
> > for(int i = 0; i < poi.getCommenti().size();i++){
> > item = poi.getCommenti().get(i);
> > commento = li.inflate(R.layout.commento, null);
> > commento_data = (TextView)
> > commento.findViewById(R.id.commento_data);
> > commento_descrizione =(TextView)
> > commento.findViewById(R.id.commento_descrizione);
> > commento_name = (TextView)
> > commento.findViewById(R.id.commento_nome);
> > commento_foto = (ImageView)
> > commento.findViewById(R.id.commento_foto);
> > Log.d(TAG, "commento_foto:"+commento_foto);
> > commento_data.setText(item.getData());
> > commento_descrizione.setText(item.getTesto());
> > commento_name.setText(item.getUtente().getName());
> > contenitore_commenti.addView(commento);
> > image[i] = new ImageViewURL(commento_foto,
> > item.getAnteprimaURL());
> > }
>
> > // I start only one thread for all images
> > thread_image_commenti = new ImageThreadURL(this);
> > thread_image_commenti.execute(image);
>
> > On 1 Apr, 10:09, Kostya Vasilyev <kmans...@gmail.com> wrote:
> >> li.inflate(R.layout.commento, null);
>
> >> gives you a new view object hierarchy each time.
>
> >> The rest is... probably bugs in your code.
>
> >> I see that you do
>
> >> new ImageViewURL(commento_foto,item.getAnteprimaURL()
>
> >> twice for each "commento" item. Doesn't seem right to me.
>
> >> -- Kostya
>
> >> 01.04.2011 11:49, pedr0 пишет:
>
> >> > Hi,
>
> >> > I am a little bit confused about this piece of code :
>
> >> > for(int i = 0; i<  poi.getCommenti().size();i++){
> >> >                    item = poi.getCommenti().get(i);
> >> >                    commento = li.inflate(R.layout.commento, null);
> >> >                    commento_data = (TextView)
> >> > commento.findViewById(R.id.commento_data);
> >> >                    commento_descrizione =(TextView)
> >> > commento.findViewById(R.id.commento_descrizione);
> >> >                    commento_name = (TextView)
> >> > commento.findViewById(R.id.commento_nome);
> >> >                    commento_foto = (ImageView)
> >> > commento.findViewById(R.id.commento_foto);
> >> >                    commento_data.setText(item.getData());
> >> >                    commento_descrizione.setText(item.getTesto());
> >> >                    commento_name.setText(item.getUtente().getName());
> >> >                    contenitore_commenti.addView(commento); //
>
> contenitore_commenti is>> > an LinearLayout
> >> >                    image[i] = new ImageViewURL(commento_foto,
>
> item.getAnteprimaURL());>> >                           thread_image_commenti = new
> >> > ImageThreadURL(this);
> >> >                    thread_image_commenti.execute(new
>
> ImageViewURL(commento_foto,
>
>
>
>
>
>
>
> >> > item.getAnteprimaURL()));
>
> >> >            }
>
> >> > thread image is a simple thread which do a download of an image and
> >> > take 2 param:
>
> >> > 1) an ImageView where thread call setImage(Bitmap)
>
> >> > 2) an String representing an URL (for download image)
>
> >> > The problem is that I can see all my photo flicker when a single image
> >> > is downloaded and all photo have the same image (URL are not the
> >> > same).
>
> >> > This is the right way ? Inflate  a NEW view for each element create a
> >> > NEW VIEW OBJECT for each iteration or them are the same object ?
>
> >> > What's wrong?
>
> >> > Thanks a lot in advance.
>
> >> > pedr0
>
> >> > --
> >> > undefined
>
> >> --
> >> Kostya Vasilyev --http://kmansoft.wordpress.com
>
> > --
> > undefinedI a
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

--
undefinedY

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment