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. ParseException: At line 1, column 0: not well-formed (invalid token)

Hi Dear,

i am totally lost in this error:

org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column
0: not well-formed (invalid token)

i have spent the whole day trying to figure out why i am getting this
error but not seems to have any luck

here is the faulty code android doesn't like

Xml.parse(is, Xml.findEncodingByName("UTF-8"), handler);



as far as i know, nothing wrong in the xml below in my sdcard.

<?xml version="1.0" encoding="utf-8"?>
<download>
 <file id="page1"/>
 <file id="page2"/>
 <file id="page3"/>
</download>




please anybody help me out
--~--~---------~--~----~------------~-------~--~----~

2. custom progress bar

i want to draw a custom progress, and I googled around and came up
with this --

in res/drawable, I have the following xml

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/
android">
     <item android:id="@+android:id/background"
           android:drawable="@drawable/progress_background"/>
     <item android:id="@+android:id/SecondaryProgress"
           android:drawable="@drawable/progress_background"/>
     <item android:id="@+android:id/progress"
           android:drawable="@drawable/progress"/>
</layer-list>

then to use it, in my main xml, I have --

<ProgressBar android:id="@+id/ProgressBar"
                     style="?android:attr/progressBarStyleHorizontal"
                     android:progressDrawable="@drawable/progress_bar"
                     android:layout_width="fill_parent"
                     android:secondaryProgress="100"
                     android:progress="50"
                     android:max="100"
                     android:layout_height="wrap_content"/>

My question is, what should "progress_background.png" and
"progress.png" look like in terms of dimensions?

Do they need to have the same height?  Same width?  How does it draw
the progress at an arbitrary percentage?

tia.
--~--~---------~--~----~------------~-------~--~----~

3. Looking for sample of video capture with preview

4. rild reboot repeatly because of "EOS. Closing command socket."

5. How can I find my GPS location with GPS sensor

6. AndroidAPI App

7. how to disable auto-rotation feature