Once again I am having trouble with listpickers.
In December, I was trying to get a listpicker to change lists and stay open. Eventually, I found out that couldn't happen and decided to switch between 2 listpickers, going back and forth as the lists change. I then ran into another problem, which was that the first listpicker was not switching lists, and it was only showing the preset list. I figured out that it was because of the set.listpicker block in the before picking event handler. Now, how do I get the listpicker to reset to the original list when the user clicks on it again without using that event handler?
Here's the code- the listpickers are supposed to switch back and forth, and then list1 is supposed to reset to the original list after the user is done picking.
You could use this sample app, if you replaced its three column table with your own link classifications and links.
Columns 1 and 2 are for navigation.
The stack variable is for backtracking.
@ABG Thanks for your help. Here's my solution:
I made the blocks for list 1. After picking and list 2. After picking into 1 big procedure with the parameters Selection (list selection), Elements (list's elements), and Index (Selection Index). I put a list1.beforepicking handler down with an if statement with a setlist1.elements block inside, setting list.elements to the original list inside if global listlogic is true. At the beginning of each branch, I made the variable list logic false, and at the end of each branch i made the variable listlogic true again. This makes it so the list is reset to the original list every time it is done w/o glitches
If you do the download right, like you did, without editting the image, you can drag the .png file into a Blocks Editor workspace and AI2 will use the hidden text in the file to recreate the blocks.
I save .png files of all my reusable procedures, by procedure name, to avoid having to recode them in other projects.
I usually use the BeforePicking event to load Elements on the fly.
GotFocus()
Indicates the cursor moved over the ListPicker so it is now possible to click it.
This looks like it is intended for eye candy, to help the user see which component is currently under his finger and help him see if it is okay to click there. For such an event I would temporarily increase font size in that component.
Regarding the Before Picking event, this is most useful for cases when you need to change the available Elements depending on run time factors.
For example, say you sell clothing by mail.
Your order form has these list pickers:
Category (shoes/shirts/pants)
Material (leather/flannel/khaki/suede)
color (red/black/brown/white)
size (depends on item and stock availability)
As the customer Selects from each List Picker going down the list, you need to refill the Elements of each List Picker going down the list to reflect what you sell and what you still have in stock (i.e. size 13 brown leather shoes)
@ABG and @TIMAI2, I could also put down a button and make the listpicker not visible. I could put a setlist1.elements block in it and a calllist1.open block after that. I think it would work in theory, as long as I make its image the one I'm using for the current listpicker, but I don't know for sure. What do you guys think?
Edit: Like this ↓ (the x is because it was a duplicate event handler)
@ABG Both worked fine. I tried out the gotfocus component and the button, and both reset the listpicker to the first list. I am going with the button, just my preference. I haven't really worked with the got focus components yet, but i think they might come in handy for situations like these.
Do you know if the dev. are going to take it out? Because, as others have said,
and it might not be necessarily needed, since androids have updated past that point.
Put a sample of your application here in the aia file. After testing, maybe some better solutions will emerge.
Without seeing what the application is doing, it's hard to give advice. I only saw that you are using list view to change application settings.