Lists List
Based on the overview of the previous section, we have probably learned about the Lcdui package, and now let's introduce some of the important classes in the screen class, and our current home is a subclass list of screens, which has three specific types: implicit (simple), Exclusive (radio), multiple (multi-selection).
Application operations related to the list element can generally be summarized as an item command or a screen type command, whose scope is judged by whether the operation affects the selected principle element or the entire list, and the operations on the list object include inserts, append and delete, the class used to constrain the list specific type is choicegroup, and the elements in the list can be manipulated by getstring, insert, set, append, delete, GetImage, and so on. For the selection of the project we use Getselectedindex (), setSelectedIndex (), Getselectedflags (), Setselectedflags (), and isselected to process, Let's introduce the three list types mentioned in the first paragraph.
Exclusive (Radio type)
As with all lists, we can specify his title and type (constructor type 1) in the constructor, or you can use another constructor type, which is to pass directly to a string array and an image array, which can be directly applied to the list The content is initialized (the constructor type, that 2).
In Type 1, when we need to add content to it, we need to use the Append () method mentioned earlier,
The first parameter of the constructor is the text on the screen, the second is the icon that represents the option, when the icon is not needed, and most of our processing methods are the same, just pass in the null parameter, and we can insert the item at any time with the Insert () method, with the set () method to reset a project, when we do not need a project, you can use the Delete () method to delete the specific options, we simply go to the method to pass the index value, we need to note that our index value is starting from 0, DeleteAll () This method deletes all the contents of the specified list at once.
In the command processing function commandaction (), we can use the methods mentioned above to detect the user's selected operation, and define the corresponding processing function to achieve the corresponding processing effect.
Implicit (implied type)
implicit (implied) in fact, and the above radio is no big difference, the only difference is that there are some subtle differences in the processing mechanism of the command: the CHOICE.IMPLICIT type list immediately triggers an event after the user chooses, and pass List.selectcommand as the first argument.
If we do not want the List of this type to be passed in as the first parameter of commandaction () when pressed, we can use Setselectcommand (null) to turn it off, and note that the consequence of doing so is to make
Commandaction () The first parameter that is accepted is null.