快速业务通道

MIDP高级UI的使用(四)Alert - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-25
  }   /**    * 崙夛宸倖MIDlet議児云?幣    * 壓宸倖Form戦中厘断辛參僉夲Alert議光嶽窃侏才蒙來    */   private void showOption(){     if(firstTime){       /**        * 栖徭猟亀議傍苧?ChoiceGroup窃祥頁僉?怏?辛參功象万議窃侏栖畳協万頁汽僉珊頁謹僉?載?List窃        * A ChoiceGroup is a group of selectable elements intended to be placed within a Form.        * The group may be created with a mode that requires a single choice to be made or that allows multiple choices.         * 參和喘議頁宸嶽更夛痕方栖幹秀ChoiceGroup議        * public ChoiceGroup(String label,           int choiceType,           String[] stringElements,           Image[] imageElements)        */       ChoiceGroup types = new ChoiceGroup("Type",ChoiceGroup.POPUP,typeStrings,null);       mainForm.append(types);       ChoiceGroup timeouts = new ChoiceGroup("Timeout",ChoiceGroup.POPUP,timeoutStrings,null);       mainForm.append(timeouts);       String[] optionStrings = {"Show Indicator"};       ChoiceGroup options = new ChoiceGroup("Options", ChoiceGroup.MULTIPLE, optionStrings,null);       mainForm.append(options);       mainForm.addCommand(CMD_SHOW);       mainForm.addCommand(CMD_EXIT);       mainForm.setCommandListener(new AlertListener(types, timeouts, options));       firstTime = false;     }     //譜崔輝念?幣議完悶     display.setCurrent(mainForm);   }   //蕗苧匯倖坪何窃?写覚CommandListener俊笥   private class AlertListener implements CommandListener{     //壓坪何窃戦中蕗苧叱倖忖粁     AlertType[] alertTypes ={       AlertType.ALARM, AlertType.CONFIRMATION, AlertType.ERROR, AlertType.INFO, AlertType.WARNING     };     ChoiceGroup typesCG;     int[] timeouts = { 2 * SECOND,4 * SECOND,8 * SECOND, Alert.FOREVER };     ChoiceGroup timeoutsCG;     ChoiceGroup indicatorCG;        public AlertListener(ChoiceGroup types, ChoiceGroup timeouts, ChoiceGroup indicator){       typesCG = types;       timeoutsCG = timeouts;       indicatorCG = indicator;     }        //糞?CommandListener俊笥嶄議渇?圭隈?功象?哘議Command斤??燕??哘議佩葎     public void commandAction(Command c, Displayable d) {       if(c == CMD_SHOW){         //資函ChoiceGroup議僉夲?           int typeIndex = typesCG.getSelectedIndex();         Alert alert = new Alert("Alert");         alert.setType(alertTypes[typeIndex]);            int timeoutIndex = timeoutsCG.getSelectedIndex();         alert.setTimeout(timeouts[timeoutIndex]);         alert.setString(typeStrings[typeIndex]+" Alert, Running "+ timeoutStrings[timeoutIndex]);   

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号