"Introduction to Java Mobile/PDA Programming" Reading notes 3--lcdaui Advanced API list

Source: Internet
Author: User
Tags int size
Notes | program | advanced | design
The screen class has four subclasses: Alert List TextBox Form

List according to the definition of Choice interface, divided into: choice.exclusive (radio) Choice.multiple (multiple selection) choice.implicit (Simple type of radio)

Single selection Image img=image.createimage ("/a.png"); List l=new list ("list Test", choice.exclusive); L.append ("Banana", IMG); L.append ("Apple", null);d isplay.setcurrent (L) ;

Insert () Inserts a new item after a specific item. Set () can reset an item. ...... SYSTEM.OUT.PRINTLN ("You have choice the" +l.getselectedindex () + "item."); System.out.println ("The content is:" +l.getstring (L.getselectedindex ()));

Multi-selection list l=new list ("list Test", choice.multiple) ... int size=l.size (); for (int i=0;i<=size;i++) {if (l.isselected (i)) {SYSTEM.OUT.PRINTLN ("You have selected" +i);}

Getselectedflags () returns a Boolean array to see if that option is selected.

Simple Radio list l=new list ("list Test", choice.implicit) ... public void commandaction (Command c,displayable s) {if (c== List.select_command) {list tmp= (list) S;int i=tmp.getselectedindex (); SYSTEM.OUT.PRINTLN ("You have selected" +i)} ...}

Choice.implicit immediately after the user chooses, the event is raised and List.select_command is passed through the first parameter C of Commandaction (). If you do not want this, you can turn it off Setselectcommand (null), at which point C=null.setselectcommand (x)--x is another command object, and when the list is selected, X acts as the Commandaction ( The first parameter is passed in.

After Setselectcommand (), the command--x is automatically added to the System menu by AddCommand (). Removecommand (c) as follows: Setselectcommand (null); Removecommand (c);

The fitpolicy mechanism provided by the choice interface determines how the text content will be processed when it is too long to automatically wrap choice.text_wrap_off-long text automatically truncated choice.text _wrap_default-according to and different from each other, usually one of the first two


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.