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. 
 http://developer.android.com/resources/tutorials/views/hello-listview.html 
gives a hint on how to do it, whilst not directly addressing the
question.

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 ?

Thanks


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. How to overlay animation upon a Vie

Hi,all,

I am new to Android and current try to realize a UI that a
drawableAnimation can keep floating upon a customized view as a small-
animating widget while I can still focus on and work on the customized
view.

Actually I tried serveral solutions but all failed as follows,

(1) I tried to use the customized view in the main activity and send a
new intent to start another activity to show the small-animating
widget, but the new activity turned to be full-screen and black
background even I set the theme as transprarent(this is also the
confusing isse for me, the new activity is always black background,
event I set transparent attribute in small-animating widget's
overriden OnDraw() method).

(2)I tried to put the small animation widet into a dialog view but
unfortunately it turn to be just another activity and block the main
activity, I have to press the Button BACK to close the small-
animation-showing dialog to use the main activity.

(3)I tried to the SurfaceView. I learned from ApiDemo that implemented
the main activity viewas one of the Surface View and plus the small
animation widget as a normal view in another xml file. But again the
sad thing is I found my customized main activity view had already
inherited from ListView and cannot be multi-inherited.

(4)I also tried to merge the small-animate widget view in to main.xls
and set the zAxis attributes as TOP ,  but it seems not work.(The
animation widget turned out to be in the same layer with other views,
squeezed the layout and broke it)

As a result, I am getting a little bit despair about the solutions.
Any better idea to help me out?
Thanks in Advance.

Regards,
Shawn

--~--~---------~--~----~------------~-------~--~----~

2. Notepadv1 tutorial

When I load the Notepadv1Solution app from the tutorial Im get an
error and can't run it. I don't understand the error. Help please.

--~--~---------~--~----~------------~-------~--~----~

3. Problem with Notepadv1 tutorial

4. Accelerometer Applications

5. "Failed to reopen debug port for Selected Client to: 8700" error

6. About Google Map Installation on Target

7. How to overlay animation upon a View