0

We are creating this Bar machine where the machine is hooked up to a server. From a client (in our case an Android application), you can mix your drink.

Problem is that we started out with 4 different liquids. But if we want the project to be more dynamic, we want to be able to have more or less than 4 liquids in the machine.

In our app we have for each liquid a Seekbar and textviews for displaying fluid name and volume while dragging the Seekbar.

The app client receives fluid information from the server.

If we wish to have let's say 5 fluids, can I somehow add more seekbars and textviews from the code? I'm having difficulty seeing that, because with 4 liquids all Views are made in the xml-file with RelativeLayouts.

Have searched for it but have only seen ListViews but my UI is more complicated than plain textviews.

  • 2
    yes, it is possible ... use google to find similar questions here before asking – Selvin Apr 30 '15 at 09:21
  • Check this out http://stackoverflow.com/questions/27128425/add-multiple-custom-views-to-layout-programmatically – cool Boy Apr 30 '15 at 09:29
  • 1
    Would you mind specify what I should look for when using google? – David Tran Apr 30 '15 at 09:30
  • Probably, that is what you are searching for... [How to Programmatically Add Views to Views][1] [1]: http://stackoverflow.com/questions/2395769/how-to-programmatically-add-views-to-views – AlexejWagner.java Apr 30 '15 at 09:30

1 Answers1

0

ListView use an ListAdapter that you have to implement, the ListAdapter can be used for anything (not only TextView).

Android ListView

If you want to add a view to a ViewGroup (LinearLayout, RelativeLayout, ...), you can also use :

BenC
  • 8,729
  • 3
  • 49
  • 68
Blusky
  • 3,470
  • 1
  • 19
  • 35