Following on from my recent post on Dynamic Lists for Listpickers, I ventured a bit further.
Well I now have a rough version (and it is ugly!) that creates a dynamic list for the first list in a nested listpicker. This assumes a list of names or words in the master list, and that these are sorted alphabetically. The issue with creating such a thing is that, say for names, there are 26 letters that names could start with, but that the distribution of names is very uneven. In my sample list 3 letters took over 30% of the entire list. My aim was to present nested lists that could all be viewed without scrolling (between 10 and 12 items), but because of the above this is just not possible all the time. I only have the blocks here that create the first list for the listpicker, the A-D,E-H,etc. as the blocks probably need some optimisation before writing the whole thing out. But here goes:
Lots of variables including an alphabet list
The init and gotText fetching the external list of names (first and surname in each cell), calling three procedures and displaying various outputs
In this procedure i get the first letters for each name, and then count the number of letters, and get those counts into a list, that corresponds with the alphabet list
A simple one (courtesy of Ghica and others), that finds the letter with the biggest number of appearances. This is used to set the “optimal” size of the nested list.