2014년 12월 11일 목요일

Variable number of input fields in application depending on user input

Could you please advice if it is possible to implement following feature in App Inventor 2 application:
user input a number, and, depending on that number software present number of input fields accordingly i.e.:

For 1 object - there are six input field in application - software doing some math and presenting result.

But if user select 2 as number of objects - there should be 12 input fields, 6 input fields for each object
and result would be displayed as result for 1st object + results for second object.

For 3 input object there should be 18 input fields... e.t.c.

Is it possible to implement something like this ? And if so - could you please advice how ?



Yes, you could do something like what you describe.  Be aware, with AI2, it is not possible to create objects dynamically.  This means if you need an input field, it has to be already created.  If somewhere in your app, you need 18 input fields, you have to have 18 on the screen (most of them can be hidden until needed).

How could you do this?
Object1 == a vertical layout with 6 input fields

Object2 == a vertical layout with a vertical layout with 12 object fields

however Object 1 could be a subset of Object 2   that would have 6 visible input fields and 6 invisible fields;  if 12 inputs reaquired set TextBox.Visible to True for the other six.

Object3  18?    Well, yes but  then you will have to have 18 Text boxes.

You can hide the unwanted boxes with IF then statements, or more elegantly with Lists and using the Advanced Component for TextBoxes.
You can also hide vertical arrangements if they are not needed.

What have you tried?



Thank you very much for your suggestion. Indded as a workaround solution that you propose could work.
I have to evaluate if it would be applicable to the program that I am trying to plan - because initially I plan
to support quite large number of input fields - so have to think if usage of App Inventor 2 would be
applicable or if I should just go for regular application development.


댓글 없음:

댓글 쓰기