2012-01-09 10 views
0

こんにちはすべて私は1つの問題で立ち往生しました。 1つの画面にListFieldを実装しました。スクリーンの上に私はTitleLabel and Two Butonsを保持するためにHorizontalFieldManagerを使いました。私はリストフィールドのすべての行にいくつかの画面をプッシュしました。私の問題は、私が4行目にいるときに補給して、ボタンをクリックしてボタンを押したときに必要なものを選択したのですが、4行目に実装した画面も回避する方法が表示されます。私は、嵐9550シミュレータとBlackberry eclipse plugin5.0を使ってテストしています。私はアイデアが不足しているので、私を助けてください。ListFieldとボタンのフォーカスが同じ画面に表示されます

ナビゲーションクリックすると、この

protected boolean navigationClick(int status, int time) { 

    selectListAndButton(); 
    return true; 

}  

//のようなもので、ここであなたがScreenためonTouchをオーバーライドして、呼び出す特定の機能をイベント座標とField境界に依存する必要がselectListAndButton方法

private selectListAndButton(){ 
Field field = getFieldWithFocus().getLeafFieldWithFocus(); 
    if(field == backCustomButton){ 
     //Popped the active Screen 

    }else if(field == saveCustomButton){ 
     //Saving some Data to the Database And pushing another Screen here 
        // problem comes here if i am at 2nd row of the listfield and selects 
        something from there and clicked on the button the screen which was 

        implemented at 2nd row also appears 

    } 

    else if (_list.getSelectedIndex() == 0){  
     //Called a date picker 

    } 
      else if (_list.getSelectedIndex() == 1){  
     //Pushed some another screen 

    } 

      else if (_list.getSelectedIndex() ==){ 
     //Pushed some another screen 

    } 

答えて

0

私はそれを解決しました。答えを遅く投稿する。私は追加する行があまりないので、ListFieldというアイデアを削除しました。だから私はちょっと使っただけです。ListFieldHorizontalFieldManagerとその外観はListなので、うまく動作します。

ありがとう歓声:)

1

次のとおりです。

protected boolean touchEvent(TouchEvent message) { 
    if (isTouchInside(message, saveCustomButton)) { 
     save(); 
    } else { 
     showNextScreen(); 
    } 
} 

private boolean isTouchInside(TouchEvent messages, Field field) { 
    int eventCode = message.getEvent();  
    int touchX = message.getX(1); 
    int touchY = message.getY(1); 

    XYRect rect = field.getContentRect(); 

    return rect.contains(touchX, touchY); 
} 
+0

'isTouchInside()'メソッドが何であるかをあなたがもう少しそれを探索することができません、なぜそのと協力 'navigationclick' – BBdev

+0

タッチイベントメソッドは、デフォルトではnavigationClickを呼び出しますありません。彼らは古いコードとの互換性のためにそれを作った。あなたのコントロール/スクリーンのnavigationClickメソッドをオーバーライドしている点を除いて、これはかなりOKです。あなたのコードをデバッグしませんでしたが、touchイベントがボタンのonFocusを呼び出さない、またはフォーカス獲得の前にUIスレッドキューとnavigationClickプロセスにいるようです。 –

+0

それは私のために働くとすぐに私はあなたに工藤を与えるだろうと私は説明してくれたために+1してください... – BBdev

関連する問題