2012-03-15 72 views
0

我使用browserfield顯示網頁。它顯示很好。使用keyChar()覆蓋方法時無法輸入值

我重寫了keyChar()方法,當點擊空格鍵時滾動頁面。它也工作正常。

protected boolean keyChar(char c, int status, int time) 
    {  
     if(c == Keypad.KEY_SPACE) 
     { 

      listContainer.setVerticalScroll(); 

     } 
    } 

    return true; 
} 

我的問題是,當我顯示此頁http://special.belo.com/wcnc/mobile/ad_form/我不能在文本框中輸入文本。 keyChar()覆蓋方法不允許在文本字段中輸入文本。

請幫我。如何在browserfield上顯示的頁面上輸入文字。

回答

1

你正在捕獲所有的鍵,但只處理空間。通常的模式是當你完成你的工作時調用超級方法:

protected boolean keyChar(char c, int status, int time) {  
    if(c == Keypad.KEY_SPACE) { 
      listContainer.setVerticalScroll(); 
    } 
    return super.keyChar(c, status, time); 
} 
+0

是的。非常感謝你。我從你那裏得到了一些知識。 – RVG 2012-03-15 06:36:17

+0

它的工作正常。但是當我按下退格鍵時,它會拋出非法狀態表達式。它只顯示在balckbrbr模擬器上。 – RVG 2012-03-21 06:19:46

+0

退格鍵由super方法處理,也許在實際的上下文中不允許。試着找出它發生的地方,嘗試獲得堆棧跟蹤,這可能值得關於SO的另一個問題!它不會拋在* this *方法中。 – 2012-03-21 06:27:48