Exactly the same problem!
Any ideas?
On Jul 23, 10:20 am, Ola Ingvaldsen <[email protected]> wrote:
> I am having the same problem. In my case it only happens if I specify my own
> layout using setContentView in onCreate() of my ListActivity. If i use the
> standard layout i get correct number of calls to getView.
>
> The thing is that if I have 5 items in my list i suspect the first 5 calls
> to getView to have convertView=null each time. But its not. First time its
> null, then the next 5 calls have the same convertView as the previous call
> and then 5 more calls where the convertView is null. So the first 6 calls
> to getView only results in changing the first element 5 times more than
> whats necessary. After the 5 first calls the convertView is null and the
> rest of the items in the list are filled out correctly. But when i scroll
> down the list, we have 10 more calls again.
>
> Does anybody have an idea whats wrong? Or how it can be avoided?
>
> I have no weights in my layout at all. Its just a simple textView with a
> status message and a listView.
>
> -Ola
>
> On Wed, Jul 15, 2009 at 4:05 PM, Streets Of Boston
> <[email protected]>wrote:
>
>
>
>
>
> > I'm not a google engineer, so i don't know the answer, but i have a
> > theory why this may happen.
>
> > In your layouts, do you use 'weights' (weightsum and layoutweight)?
> > If i remember correctly, if you use these attributes, layout-code is
> > called twice.
> > If the layout-code for a list-view includes the 'getView' then this
> > would explain it being called 4 times for 2 child views.
>
> > On Jul 15, 2:40 am, Mika <[email protected]> wrote:
> > > Hi,
>
> > > I'm having the same problem. Did you find any solutions??
>
> > > -Mika
>
> > > On Jun 24, 7:39 pm, jabu <[email protected]> wrote:
>
> > > > Hi Everyone,
>
> > > > I am implementing my ownadapterthat inherits from BaseAdapter (this
> > > > is something very classic).
> > > > Then when I start the activity that owns the listView binded to
> > thisadapterI can see that the getView() method is called moretimesthan
> > > > what the number of view actually available in the list.
> > > > For instance, I do have 2 rows in my list and when I first set
> > theadaptergetView is called 6times. Then If I make a call to
> > > > notifyDataSetChanged(), getView is called 4times.
> > > > I understand that when you scroll up and down getView must be called
> > > > to generate or re use a view but I don't scroll up or down, I am
> > > > really wondering why getView is called so many time.
>
> > > > Thanks a lot in advance for your responses.
> > > > Jabu
>
> > > > My code just in case even though it is a pretty basic piece of code:
>
> > > > public View getView(int position, View convertView, ViewGroup
> > > > parent)
> > > > {
> > > > ViewHolder holder;
> > > > if (convertView == null)
> > > > {
> > > > convertView =
> > mInflater.inflate(R.layout.row_action, null);
> > > > // Creates a view holder
> > > > holder = new ViewHolder();
> > > > ...
> > > > convertView.setTag(holder);
> > > > }
> > > > else
> > > > {
> > > > holder = (ViewHolder)convertView.getTag();
> > > > }
> > > > holder.params.set....
> > > > return convertView;
> > > > }- Hide quoted text -
>
> > > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---