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. Can't change MediaPlayer data source

Hello everyone.
I'm experiencing some sort of problem. Let's say I have a MediaPlayer
object wich can play an audio sound and a Resources object:

Code:
resources = new Resources(this.getAssets(), new DisplayMetrics(), new
Configuration());
mp1 = MediaPlayer.create(this, R.raw.sound1);

So when I invoke mp1.start() , sound1 plays, everything's normal.

But when I try to change the sound that my MediaPlayer should play, it
doesn't work, here is what I do:

        mp1.reset(); //=>So mp1 is in the Idle state
        mp1.setDataSource(resources.openRawResourceFd
(R.raw.sound2).getFileDescriptor()); //State : Initialized
        mp1.prepare(); //State : Prepared
        mp1.start(); //Doesn't work here!!

I'm pretty sure someone can see a mistake in my code.
Tank you for your help.

Moons


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

2. Vertical and Horizontal scroller for EditText

Hi Guys,

Can someone heklp me as to how I can add a horizontal and vertical
scrollbar for an EditText?

I need it to be done through java code and not through xml.

Regards,
R.Karthik
--~--~---------~--~----~------------~-------~--~----~

3. Urgent!!!!!!!!!Audio recording..

4. disabling scrolbar in ListView

5. ImageMatrix has no effect when ImageView is in matrix scaling mode

6. how to show big images with full resolution

7. Create Bitmap with all Changes on a DrawableBitmap