Can we programmatically generate lists, such that we don't have to manually assign a new variable to each new list?

How to programmatically generate a list (Not listview but the blue blocks)? Usually the blocks need to be put inside a variable. But we cannot generate variables, can we?

Please elaborate what you mean. I just do not understand anything.

Btw, do you mean this:
blocks (19)

Or smth else?


Yes, that kind of list, however, how can I generate that kind of list programmatically, every time a button is pressed? Is that possible? Can the variable be changed through a button press, for example, name --> name1–> name2 etc?

Why do you need this? The list will be there once you create it bc it is in a global variable. This method will crash your app.

I cannot understand for what use this is. Please

1 Like

so, like a chat for example. If I am talking to A, I want to put my conversation wit A on a separate “list” in firebase from my oconversation with B or C. So, every conversation is a separate list. Is this a bad idea?

Hi There,
There is a principal that once your application is developed it will change the data but will not change the blocks you have.

We have our blocks to do the stuff like changing the data, appearance, calculation etc.

I agree that you need to save your different chats in different place at firebase. That has nothing to do with creating new list in the blocks for each user.

Instead you can make a main list like this:
Main List
Chat 1
Sentence 1
Sentence 2
Sentence 3
Chat 2
Sentence 1
Sentence 2
Sentence 3
Chat 3
Sentence 1
Sentence 2
Sentence 3

So you don’t need to create a new variable. Instead update the existing variable i.e. Main List

The reason I want to create a new list, is so that the new list can replace a specific chat (say chat 3), when sentence 2 is introduced. Currently, it is either, having the same list for all chats, or the new sentences replacing the old for me.

I don’t have a working example for chat right now but what i am saying is keep your variable floating.

Just assign 1 chat to it at one time and when you are switching to new chat before that just save your chat 1 to firebase.

So when again when you are chatting to a person in chat 1, first get all the chat saved from firebase and then update it.

So, 1 variable for all chats (1,2 and 3)?

Your variable one should be a list, which contains other lists say list 1, list 2 and list 2 for each chat

1 Like

I see, let me try that.

I think you need to do this to get your results.

When Button1 click, it will add item to list.

Hope it will help you. :slight_smile:


Ok Thank you. I am still trying something different. I am posting something else that is puzzling me. Please take a look at it if you can. It’ll be posted in several minutes

A very good way to learn App Inventor or Kodular is to read the free Inventor’s Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps … the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps
How to do a lot of basic things with App Inventor are described here: How do you...? .

Also do the tutorials Tutorials for MIT App Inventor to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor



Okay sure. :slight_smile:

1 Like

Thank you,I solved my own problem. This thread is about programmatically creating a list, it’s not quite like what you suggested but I did not use it in the end. But thank you. I appreciate it.

1 Like

Can you share the solution? So that other with same query/doubt can get help

It is a completely different algorithm. It would be out of topic here. That’s why I didn’t mark any one’s answer as a solution. The solution has not yet been found for this specific topic.

Did you read @Taifun suggestion.
You need to add variable in list on run time of app yes then use add items in list block to add in that list

1 Like

Your question is not entirely obvious.