Text Box in While Loop

Dear All,
In my App, I have total 20 Text Boxes, I need to load data from TinyDB database.
I have do done this by loading individually to text box using Set TextBox.Text
is their any way, i can do it in while loop statement to reduce code size.

Hello prashanth

That’s a huge number of Text Boxes - I have never seen so many in any App. If the User needs to edit the data in a Text Box, you might consider using one and having the data selected from a List View.

You can process all the Text Boxes using the “Any Component” Block. The snag is, there is no way of knowing the order of the saved data in TinyDB in your current example. Give the Tag Names a prefix so that they do deliver the data in the expected order.

Thanks Chris for the solution. Here is the layout of TextBoxes. User needs to change the rates for
five chairs for corresponding duration. I though if we provide individual text box, the UI will be easy for him to change.

Well, the GUI design is up to you - but if you only presented one row of Text Boxes + Image, the User would be less likely to make an error (wrong values for item) and your App would be “Lean and Mean”.

The attached code example stores a bunch of garbage values to demonstrate how to use “any component” to retrieve TinyDb Data, and how to ensure the Tag Names force the order expected.

TinyDbToTextBoxes.aia (4.3 KB)

1 Like

Thanks for the demonstration app, Will implement in my app & let you know the result.

Implemented in my app. While saving data to tinyDB, its not in order,
Please let me know where i’m wrong…

use a list to store all the textbox texts and store that list in only one tag in TinyDB


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Thanks for the suggestion. Will try it. Could you please explain in detail ?

what I previously explained is already the detailled explanation... :smiley:
you might want to try something and if you get stuck, post a screenshot of your relevant blocks

it looks like you need this


1 Like

I have tried using List component.

But when a ran on device, it given this message
“Attempt to invoke virtual method ‘java.lang.Class java.lang.Object.getClass()’ on a null object reference”

It doesn’t have to be that difficult :slight_smile:

1 Like

Thanks Tim, Now it’s working.

can i reduce number of iteration in store_to_list & read_from_list using while loop statement

Yes, you will need a list of textbox components:

1 Like

Thanks again, It works fantastic.
Is any way, we can still reduce create list block, need to create 20 textbox.

Look in Taifun’s extension list for possibilities for creating dynamic components

you only need the list of the textbox components
the procedure store_to_list you can simplify, just use a for each in list loop and create the list of the textbox.texts dynamically using the advanced blocks, see also your procedure read_from_list

see also

How to work with the advanced features

A Multiple Choice Quiz: How to work with the advanced features


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

In this all the text boxe components are added in the list. Instead, is there any method which will extract all the components(like textbox, listview, layout....) information?
can we assign the relevant information Using component reference(unique id) and Any Component Block
Thanks in advance

you need a list with the components to be able to use the any component blocks


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.