Prakash,
You are right about recycling and getView having to reset a recycled
view with correct data values. As for the number of views the framework
keeps around - there is no clear answer to this, and I wouldn't count on
any particular number here.
Might want to take a look at these adapter overrides: getViewTypeCount
and getViewItemType. Using these, you can tell ListView that there is
more than one type of list item view. In your case, there are two: one
compact, and one with details.
You could also modify list API example #6 you're referring to. It uses
one type of list item layout, and dynamically manages visibility of some
views between GONE and VISIBLE. In the demo, any list item can be
expanded, so there is an array of booleans to track state. You could go
with one variable, the index of the currently expanded item.
-- Kostya
14.10.2010 19:05, Prakash Iyer ?????:
Hello,
I'd like to show my users a list of items and when any one is
selected, sort of expand the view. Very similar to the the List
example no 6 (List Adapter Collapsed) in the SDK where if you click on
the person you see the speech. Now in my app, I allow only one
expanded view, easy enough to do. Also, my elements are not static and
for ease of use, I extend ArrayAdapter. My questions are as follows,
1. In the getView there is a convertView parameter. I didn't see
much documentation around it but given it's name and the source,
I assume this is where the View object gets reused. In other
words, if I don't do a setText here if the incoming parameter is
non-null, I should see names/labels (of list items) getting
recycled? I assume the framework has atmost X views alive where
X could be less than the total count of items and more than a
screenful. Am I correct or reading too much into this?
2. Now, I have a TextView which I supply ArrayAdapter and then a
TableLayout which is made visible on demand. The table can have
upto N, say 50, rows. Each row has 2 columns, an immutable name
column and then the variable value column. Not every item will
have N rows, and which of the N rows are present will vary as
well. So, is the most efficient means of doing this,
1. Have the view supplied to ArrayAdapter have the
TableLayout with N rows, all with Visibility of Gone and
then fill in the vaalues in getView and set Visibility
appropriately
2. View given to ArrayAdapter has the TextView and nothing
else. Create one TableLayout object, N TableRow objects.
Add/remove TableRow objects to the TableLayout singleton
and add/remove the TableLayout singleton from the
appropriate View in getView
3. Something else altogether
Thanks a ton!
--
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
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
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