日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
J2ME中ITEM類用法實(shí)例解析

你對(duì)J2ME中ITEM類用法是否熟悉,這里和大家簡單分享一下,為了便于大家理解通過圖里向大家解釋,相信本文介紹一定會(huì)讓你有所收獲。

成都創(chuàng)新互聯(lián)公司是專業(yè)的涪城網(wǎng)站建設(shè)公司,涪城接單;提供網(wǎng)站建設(shè)、網(wǎng)站制作,網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行涪城網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!

J2ME中ITEM類用法

一、基本知識(shí)

1、ITEM類是Form類的派生類。

2、通過改變ITEM類的派生類的實(shí)例的狀態(tài),用戶可以和應(yīng)用程序進(jìn)行交互。

3、ITEM類StateChanged方法和普通觸發(fā)器不同,在用戶引起狀態(tài)變化時(shí)自動(dòng)調(diào)用的操作,程序本身引起的不會(huì)調(diào)用。

二、創(chuàng)建實(shí)踐

1、以ChoiceGroup的應(yīng)用為例,所有應(yīng)用ITEM類的MIDlet如果要處理ITEM類的狀態(tài)變化必須重寫ITEM類StateChanged方法

2、實(shí)際運(yùn)行效果圖

3、NETBEANS設(shè)計(jì)器的設(shè)計(jì)

 #p#

4、代碼(NETBEANS生成的大部分框架,筆者修改了其中幾行,增加了ITEM類StateChanged方法)

 
 
 
 
  1. packagehello;  
  2. importjavax.microedition.midlet.*;  
  3. importjavax.microedition.lcdui.*;  
  4.  
  5. publicclassHelloMIDletextendsMIDletimplementsCommandListener,
  6. ITEM類StateListener{  
  7. privatebooleanmidletPaused=false;  
  8. //  
  9. privateCommandexitCommand;  
  10. privateFormform;  
  11. privateChoiceGroupweather_CG;  
  12. //  
  13.  
  14. publicHelloMIDlet(){  
  15. }  
  16. //  
  17. //  
  18. //  
  19.  
  20. privatevoidinitialize(){  
  21. //writepre-initializeusercodehere  
  22.  
  23. //writepost-initializeusercodehere  
  24. }  
  25. //  
  26. //  
  27.  
  28. publicvoidstartMIDlet(){  
  29. //writepre-actionusercodehere  
  30. switchDisplayable(null,getForm());  
  31. //writepost-actionusercodehere  
  32. }  
  33. //  
  34. //  
  35. publicvoidresumeMIDlet(){  
  36. //writepre-actionusercodehere  
  37.  
  38. //writepost-actionusercodehere  
  39. }  
  40. //  
  41. //  
  42.  
  43. publicvoidswitchDisplayable(Alertalert,
  44. DisplayablenextDisplayable){  
  45. //writepre-switchusercodehere  
  46. Displaydisplay=getDisplay();  
  47. if(alert==null){  
  48. display.setCurrent(nextDisplayable);  
  49. }else{  
  50. display.setCurrent(alert,nextDisplayable);  
  51. }  
  52. //writepost-switchusercodehere  
  53. }  
  54. //  
  55. //  
  56.  
  57. publicvoidcommandAction(Commandcommand,
  58. Displayabledisplayable){  
  59. //writepre-actionusercodehere  
  60. if(displayable==form){  
  61. if(command==exitCommand){  
  62. //writepre-actionusercodehere  
  63. exitMIDlet();  
  64. //writepost-actionusercodehere  
  65. }  
  66. }  
  67. //writepost-actionusercodehere  
  68. }  
  69. //  
  70. //重寫ITEM類StateChanged方法  
  71. publicvoidITEM類StateChanged(ITEM類ITEM類){  
  72. //writepre-actionusercodehere  
  73. if(ITEM類==weather_CG){  
  74. form.setTitle("你選擇了"+weather_CG.getString
  75. (weather_CG.getSelectedIndex())+"天");  
  76. //writepost-actionusercodehere  
  77. }  
  78. //writepost-actionusercodehere  
  79. }  
  80. //  
  81.  
  82. //  
  83.  
  84. publicCommandgetExitCommand(){  
  85. if(exitCommand==null){  
  86. //writepre-initusercodehere  
  87. exitCommand=newCommand("\u9000\u51FA",Command.EXIT,0);  
  88. //writepost-initusercodehere  
  89. }  
  90. returnexitCommand;  
  91. }  
  92. //  
  93. //  
  94. publicFormgetForm(){  
  95. if(form==null){  
  96. //writepre-initusercodehere  
  97. form=newForm("Welcome",newITEM類[]{getWeather_CG()});  
  98. form.addCommand(getExitCommand());  
  99. form.setCommandListener(this);  
  100. //增加初始天氣選擇情況顯示  
  101. form.setTitle("你選擇了晴天");  
  102. //增加ITEM類的監(jiān)聽器  
  103. form.setITEM類StateListener(this);
  104. //writepost-initusercodehere  
  105. }  
  106. returnform;  
  107. }  
  108. //  
  109.  
  110. //  
  111.  
  112. publicChoiceGroupgetWeather_CG(){  
  113. if(weather_CG==null){  
  114. //writepre-initusercodehere  
  115. weather_CG=newChoiceGroup
  116. ("\u5929\u6C14\u7C7B\u578B",Choice.EXCLUSIVE);  
  117. weather_CG.setLayout(ImageITEM類.LAYOUT_DEFAULT);  
  118. weather_CG.setFitPolicy(Choice.TEXT_WRAP_DEFAULT);  
  119. //選項(xiàng)框項(xiàng)的代碼  
  120. weather_CG.append("晴",null);  
  121. weather_CG.append("陰",null);  
  122. weather_CG.append("雨",null);  
  123. weather_CG.append("雪",null);  
  124. weather_CG.setSelectedIndex(0,true);  
  125. //writepost-initusercodehere  
  126. }  
  127. returnweather_CG;  
  128. }  
  129. //  
  130.  
  131.  
  132.  
  133.  
  134. publicDisplaygetDisplay(){  
  135. returnDisplay.getDisplay(this);  
  136. }  
  137.  
  138. publicvoidexitMIDlet(){  
  139. switchDisplayable(null,null);  
  140. destroyApp(true);  
  141. notifyDestroyed();  
  142. }  
  143.  
  144. publicvoidstartApp(){  
  145. if(midletPaused){  
  146. resumeMIDlet();  
  147. }else{  
  148. initialize();  
  149. startMIDlet();  
  150. }  
  151. midletPaused=false;  
  152. }  
  153.  
  154. publicvoidpauseApp(){  
  155. midletPaused=true;  
  156. }  
  157.  
  158. publicvoiddestroyApp(booleanunconditional){  
  159. }  
  160. }  
  161.  

文章題目:J2ME中ITEM類用法實(shí)例解析
網(wǎng)址分享:http://m.5511xx.com/article/dhedesh.html