Recommendations for variable length ListBox

by Peter Webb » Thu, 21 Oct 2010 13:59:15 GMT

Sponsored Links
 All of the examples of the use of ListView and similar controls that I
can find assume a fixed number of field names coded into @strings or
similar, and retrieved through R.layout functions.

I want to dynamically create ListViews, Linear Layouts, Spinners etc
of variable length, and contents determined at run time.

I assume this is possible. Various appraoches occur to me:

Extend ListView with a custom creator that pre-populates with the
runtime determined field names. 
gives a hint on how to do it, whilst not directly addressing the

I could try and take out the requirement to go through R.layout, and
directly reference some other data structure

And some others.

However, this must be a very common design pattern, can anyone tell me
the recommended approach for allocating the number of items in (say) a
List View and their content at runtime ?


Peter Webb


Recommendations for variable length ListBox

by Kumar Bibek » Thu, 21 Oct 2010 16:08:12 GMT

 Sure you can do that. There can be as many number of ViewTypes you
want. And as many layouts. Also, you can create the views at runtime,
depending on the requirement.

There are a few methods in the BaseAdapter class which will help you.
Search for them (getItemViewType or something)

Sponsored Links

Other Threads

1. hw home screen works.?

hi all,

I need a help regarding HomeScreen. I was thinking hw the size of the
Workspace is defined. LIke hw it streaches it self. is it a 9.png image or
some thing else.
please let me knw .
if anyone have this information.



2. How to push a screen to background, without destroying the Surface?

I want to hide my app screen and then when the user clicks on the app
again, I want to bring it to the foreground , but I want the app to
maintain the screen that was pushed to background. Is there any way
do that right now?.  Because when I try to hide my app, the surface
my app is gettng destroyed and so when I try to relaunch the app a
surface is created and my app status is changing.

Anu G.


3. APN Problem

4. ViewFlipper with just one View

5. Activity - get notified when all views are rendered

6. How to scroll/move text within TextView on home screen widget ?

7. Supportting multiple MPEG-4 decoders??