Hello all,

So I've got a ListView setup in my xml with height 0dip (I don't know
the height yet).

Then I setup an adapter with my custom getView() implementation and
set is as the ListView's adapter.

I then get the layout params from the ListView via getLayoutParams()
into variable 'infoLayoutParams'.

If I then set the height of the ListView via infoLayoutParams to like
400 and do a requestLayout(), the ListView is shown. So far so good.

But the height 400 is just for testpurposes. I'd like to compute the
height, based upon the height of items in the ListView. Let's say I
want to set the height of the ListView to the height of the first 5
entries added up (so at least those 5 will  always be shown). Thus I
need to retrieve the height for each item; since they are of variable
height, I can't take some constant value.

So I tried getHeight() on the view --> returns 0.
Then I tried getting the adapter from the ListView and requesting its
views myself via getView() and doing a getHeight() on that view -->
returns 0.
Is 0 being returned because none of the (item and list) views have
been layout-ed yet?

I searched on the forums for an answer but no luck ther either.

Thus the question is: is there a way to get the height of each item in
a ListView, while for the ListVIew the height has not been set yet?
(on one hand it makes sense you can't because the LV isn't layout-ed
yet. But that then implies you can never compute based upon the height
of the items right?)

Regards,
Marco





--~--~---------~--~----~------------~-------~--~----~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to