2012-02-02 94 views
0

我打開一個應用程序,我拿一個標籤&一個按鈕。如何知道配置文件更改爲黑莓手機的振動模式?

我想要當用戶點擊那個按鈕'選擇配置文件'彈出屏幕打開。

當用戶選擇振動曲線則標籤必須設置爲「振開」 &爲其它規範它被設置爲「振落」

我嘗試過,但該標籤不選擇配置文件後immideatly設置。

這是我的代碼

public final class MyScreen extends MainScreen 
{ 
    /** 
    * Creates a new MyScreen object 
    */ 
    LabelField lbl; 
    ButtonField btnOk; 
    public MyScreen() 
    {   
     // Set the displayed title of the screen  
     setTitle("MyTitle"); 
     lbl=new LabelField("Set profile "); 
     btnOk=new ButtonField("OK"); 
     btnOk.setChangeListener(new FieldChangeListener() { 

      public void fieldChanged(Field field, int context) { 
       // TODO Auto-generated method stub 
       try { 
        ApplicationManager .getApplicationManager().launch("net_rim_bb_profiles_app"); 
       } catch (ApplicationManagerException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
       if(NotificationsManager.isVibrateOnly()) 
       { 
        lbl.setText("Vibration on"); 
       } 
       else 
       { 
        lbl.setText("Vibration Off"); 
       } 


      } 
     }); 
     add(lbl); 
     add(btnOk); 

    } 
} 

Pleease請幫幫我,1周做.......

+0

我也通過添加GlobalEvent Listener使用,但它不顯示設備的變化,但在模擬器上工作。請幫助,如果任何人有想法。 – iWatch 2012-02-02 09:06:06

回答

2

覆蓋OnExposed(),並在該方法中寫道下面的代碼

invalidate(); 
if(NotificationsManager.isVibrateOnly()) 
     { 
      lbl.setText("Vibration on"); 
     } 
     else 
     { 
      lbl.setText("Vibration Off"); 
     } 

這對我很好。 :):D