Search code examples
javaandroiduser-interfacemobile-phonessmartphone

Question about creating GUIS "dynamically" on Android


I'm trying to make an android app (I'm new in the Android programming world), and I'm having problems creating the GUI.

The point is that I get information of some data that is divided in days... The problem is that I don't know, until I retrieve the information, how many days the GUI should display.

http://img574.imageshack.us/img574/3787/mainscreen.jpg

The grey part will be a TextView, and, also, the black part will be another TextView with multiple lines.

So, the point is, how can I do to have multiple TextView's without knowing before the exact number? I suppose that I can't declare them in the layout.xml

The only solution that I've been thinking about is to create in the layout 7 pairs of TextView and, when I know the exact number, just use what I have to, and don't use the others... (It's a bad solution)

What do you suggest?

Thank you for your answers!


Solution

  • You should create a ListView, which inflates TextView for the items you have.

    You can use this example of how to create sectioned ListView, which will look exactly like you want.