Don't re-inflate each time.  Implement this correctly, where you re-use the
convertView if it is given.  Just make sure you have the states of the views
set up correctly before you return.

On Thu, May 12, 2011 at 8:14 AM, authorwjf <[email protected]> wrote:

> Yahel's post got me to thinking.  I modified the getView method of my
> data adapter to look like this:
>
>
> @Override
> public View getView(int position, View convertView, ViewGroup parent)
> {
>    LayoutInflater vi =
> (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
>    View v = vi.inflate(R.layout.list_view_row, null);
>    TextView label = (TextView) v.findViewById(R.id.label);
>   ImageView spinner = (ImageView) v.findViewById(R.id.spinner);
>   MyContainer item = (MyContainer) items.get(position);
>   label.setText(item.getText());
>   spinner.setVisibility(View.INVISIBLE);
>   if (item.isLoading()) {
>      label.setText("***"+item.getText()+"***");
>      spinner = (ImageView)v.findViewById(R.id.spinner);
>      spinner.setVisibility(View.VISIBLE);
>      Animation spinnerAnimation =
> AnimationUtils.loadAnimation(getContext(), R.anim.rotate);
>      spinner.startAnimation(spinnerAnimation);
>   }
>   return v;
> }
>
>
> And the problem seems resolved!  Great news for me.  Though I wonder
> if any of you can comment as to the performance hit / impact I might
> expect to take reloading the view from the layout every single time
> the adapter refreshes?  I'm not experiencing any issues with the demo
> program, but the lists in my actual application can get rather long
> and include several lines of text for each row.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

Reply via email to