自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

BlackBerry應(yīng)用開(kāi)發(fā)指南 監(jiān)聽(tīng)UI對(duì)象的改變

移動(dòng)開(kāi)發(fā)
本文為《BlackBerry應(yīng)用開(kāi)發(fā)指南》UI設(shè)計(jì)篇的最后一章——監(jiān)聽(tīng)UI對(duì)象的改變,UI EventListeners 允許應(yīng)用程序響應(yīng)一個(gè) UI 對(duì)象的改變。這里有 3 種類型的 UI 事件監(jiān)聽(tīng)者 :監(jiān)聽(tīng) field 屬性的變化、監(jiān)聽(tīng)焦點(diǎn)的改變和監(jiān)聽(tīng)滾動(dòng)事件。

UI EventListeners 允許應(yīng)用程序響應(yīng)一個(gè) UI 對(duì)象的改變。這里有 3 種類型的 UI 事件監(jiān)聽(tīng)者 :

監(jiān)聽(tīng) field 屬性的變化

為了監(jiān)測(cè) field 的變化,實(shí)現(xiàn) FieldChangeListener 接口。調(diào)用 setChangeListener()來(lái)把你的實(shí)現(xiàn)指派給一個(gè) field。

  1. private class  
  2. FieldListener  implements implements implements  
  3. implements  
  4. FieldChangeListener  {  
  5. public void  
  6. fieldChanged(Field ,  int context)  {  
  7. if  
  8. (context  !=  FieldChangeListener.PROGRAMMATIC)  {  
  9. //  Perform  action  if  user  changed  field.  
  10. }  
  11. else {  
  12. //  Perform  action  if  application  changed  field.  
  13. }  
  14. }  
  15. }  
  16. //  ...  
  17. FieldListener  myFieldChangeListener  =  new  FieldListener()  
  18. myField.setChangeListener(myFieldChangeListener); 

#p#

監(jiān)聽(tīng)焦點(diǎn)的改變

為了監(jiān)測(cè) field 之間焦點(diǎn)的改變,指派給他們一個(gè) FocusChangeListener 。實(shí)現(xiàn)這個(gè)FocusChangeListener,然后通過(guò)調(diào)用 setChangeListener()把你的實(shí)現(xiàn)指派給一個(gè) Field。一個(gè)FocusChangeListener 關(guān)心一個(gè)與之相關(guān)的明確的 Field 的焦點(diǎn)的獲取,失去或改變。

當(dāng) field 通過(guò)實(shí)現(xiàn) focusChanged()獲取,失去或改變焦點(diǎn)時(shí),  FocusChangeListener 的實(shí)現(xiàn)應(yīng)該指明 field 將采取什么樣的動(dòng)作。

  1. private class  
  2. FocusListener  implements implements implements  
  3. implements  
  4. FocusChangeListener  {  
  5. public  void  
  6. focusChanged(Field  field,  int  eventType)  {  
  7. if  
  8. (eventType  ==  FOCUS_GAINED)  {  
  9. //  Perform  action  when  this  field  gains  the  focus.  
  10. }  
  11.  
  12. if  
  13. (eventType  ==  FOCUS_CHANGED)  {  
  14. //  Perform  action  when  the  focus  changes  for  this  field.  
  15. }  
  16.  
  17. if  
  18. (eventType  ==  FOCUS_LOST)  {  
  19. //  Perform  action  when  this  field  loses  focus.  
  20. }  
  21. }  
  22. }  
  23. FocusListener  myFocusChangeListener  =  new  FocusListener();  
  24. myField.setChangeListener(myFocusChangeListener); 

#p#

監(jiān)聽(tīng)滾動(dòng)事件

ScrollChangeListener 接口的實(shí)現(xiàn)允許你的 field 管理器管理滾動(dòng)事件,調(diào)用 setScrollListener()將你的實(shí)現(xiàn)給一個(gè) Manager。當(dāng)水平或垂直的(或都有)滾動(dòng)值發(fā)生變化時(shí),scrollChanged()方法傳遞一個(gè)新的值。

(注:典型地,監(jiān)聽(tīng)滾動(dòng)變化沒(méi)有必要,因?yàn)槟愕膽?yīng)用程序可以監(jiān)聽(tīng) field 的焦點(diǎn)變化;盡管這樣,ScrollChangeListener 在游戲?qū)崿F(xiàn)中可能有用。)

為將監(jiān)聽(tīng)者指派給一個(gè) field,調(diào)用 field 管理器上的 setScrollListener().

  1. private class  
  2. ScrollListener  implements implements implements  
  3. implements  
  4. ScrollChangeListener  {  
  5. scrollChanged(Manager  manager,  int newHoriztonalScroll,  int   newVerticalScroll){  
  6. //  Perform  action.  
  7. }  
  8. }  
  9. ScrollListener  myScrollChangeListener  =  new  ScrollListener();  
  10. myManager.setScrollListener(myScrollChangeListener); 

【編輯推薦】

  1. BlackBerry應(yīng)用開(kāi)發(fā)指南 使用圖像對(duì)象畫(huà)圖
  2. BlackBerry應(yīng)用開(kāi)發(fā)指南 UI設(shè)計(jì)之圖片操作
  3. BlackBerry應(yīng)用開(kāi)發(fā)者指南 創(chuàng)建客戶定制的UI組件
  4. BlackBerry應(yīng)用開(kāi)發(fā)者指南 UI API篇之管理UI組件
  5. BlackBerry應(yīng)用開(kāi)發(fā)者指南 UI API篇之顯示UI組件
責(zé)任編輯:佚名 來(lái)源: 網(wǎng)絡(luò)整理
相關(guān)推薦

2011-04-15 15:16:28

使用圖像對(duì)象畫(huà)圖BlackBerry

2011-04-15 14:22:20

圖片操作UIBlackBerry

2011-04-18 11:00:34

使用音頻BlackBerry

2011-06-07 09:10:41

BlackBerry 開(kāi)發(fā)

2011-04-14 10:34:08

BlackBerry

2011-04-14 10:05:16

BlackBerry

2011-04-14 10:03:32

UI組件BlackBerry

2011-04-13 11:31:06

PIM APIBlackBerry

2011-04-13 13:38:57

選項(xiàng)APIBlackBerry

2011-04-13 09:55:16

Mail APIBlackBerry

2011-04-02 13:44:08

2011-12-05 14:50:13

Knockout

2011-12-05 15:44:45

Knockout

2012-01-04 16:21:11

2011-11-29 16:38:58

Knockout

2011-04-13 14:10:27

.alx文件BlackBerry

2010-05-22 16:57:09

BlackBerry開(kāi)

2010-04-02 17:45:22

Black Berry

2011-11-29 16:56:30

Knockout

2011-11-30 16:29:41

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)