How do I set an open listpicker to another list? (Newb mistakes?)

Hello all,

I was testing out my app, and the settings list won't work. I am trying to make the listpicker switch to another list based on the choice, and then do the code I have for the selection from the code. Any idea what I did wrong?
Here is the basic code for the two versions I tried to use (the original block is about 120+ blocks long). Please feel free to edit the code so it works.

basic .aia-Listpickers.aia (4.1 KB)
I felt like nobody should have to go through all 2,000 blocks of my app to see find what's wrong... I'll do that myself if anybody fixes this basic one, but if you want to go through the original, be my guest.
Here's the original app- Browser2.aia (66.2 KB)

Link to a better explanation- How do I set an open listpicker to another list? (Newb mistakes?)

You did not load the color selections from a Media file.

@ABGI haven't tried to use the media table yet for the theme... just uploaded the csv file to it. Baby steps... But first I have to figure out why it isn't changing to another list after i choose something. It doesn't do the set listAll.elements to get Settings List and just closes the listpicker there. The history and bookmarks options also don't open their respective lists. The list picker should get the choice, if it is settings switch to settingslist and get the choice picked, and then change the theme. Is the setlistpicker block not supposed to be there? Or is it?

What is a set listpicker1.settings_list ?

I don't understand your blocks or what you are expecting from them..
Perhaps if you explained them block by block, with pictures interposed between sentences?

@ABG After a choice is made in the list picker, it should evaluate the choice and change based on the choice. If I choose settings, it should change to another list called Settings_List. If I choose history, it should go to the history list. Same with bookmarks. None of these work...
If the choice is Incognito, then it should set the clock always ticks to false, and stop adding to the history list. If it is already stopped, then set it to always fires. This works...
And if dark mode is chosen, if it is already dark mode then it should switch it to light mode, else switch to dark mode. This works too...
Basically it is a huge block of nested if/elseif blocks that should change the list based on the choices.

The problem is that it won't switch lists when told to. It either freezes, or closes the list.
This is the block that I think is causing the problem

Can I not include this under the AfterPicking event handler? If so, how do I get it to switch lists?
Did that help your understanding?

What does Do It reveal in ListAll.Elements after you have made a selection?

@ABG Do you mean to debug? I'll be back on later or tomorrow. I'm editing this between classes.
I haven't tried the DoIt yet in the companion app... parents are restrictive on tablet usage.

Possibly this:


you call the listpicker again before handling the previous selection ?

Setting just sets two variables with the selection, and it's index.

Do It is a big help.

By the way, this business of swapping out the Elements of a List Picker in the AfterSelected event is very awkward, like asking the List Picker to hop with its pants down.

It's more natural to arrange a hierarchy of List Pickers in a row, horizontal or vertical, like bread crumbs, to progress from major to minor selection, showing their Selection values in their .Text values, like bread crumbs. The Selected List Picker uses its Selection to load the next lower List Picker's Elements. For example, think of (Country, State, City) List Pickers. That also eliminates the business of swapping out Elements while open.

The BeforePicking event is a safer place to load the Elements of a Picker.

Here is a sample app to study that reloads a List Picker on the fly.

1 Like

Thanks @ABG, I hadn't really thought of it that way.

Do I have to load the JSON files to my app in order for the list tree to work?

Reworking that block will be a pain....:hot_face:

If you are referring to using my JSON_browser code to analyze your own JSON samples, check out the buttons that load JSON or XML from the Web or Files or built-in global constants for demo purposes. Each feeds the loading and analysis differently, and can adjusted to your taste.

I provided my sample app for your edification, and not direct injection into your app.

1 Like

@ABG I will not be using the JSON code, or direct code from the app.

What do you mean by "branching" or "a branching list"? Google did not help me with that term...

@ABG Could I just replace all items in the list and then amend the list with a copy of the list I want it to show?

Maybe a simpler example will help you with your determination to alter the Elements list of a List Picker ...

1 Like

Thanks @ABG

@ABG @TIMAI2 Here's what I came up with.
I ended up using two list-pickers, with one set as not visible. I then switched back and forth based on the selection. I haven't gotten around to the theme and the colors yet (winter break just finished). I'll probably do that tomorrow.