0

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

ナビクリックはこんな感じ

protected boolean navigationClick(int status, int time) {

    selectListAndButton();
    return true;

}       

// そしてここに 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 

    }
4

2 に答える 2

1

イベントの座標と境界に応じて、特定の機能をオーバーライドonTouchして呼び出す必要があります。ScreenField

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);
}
于 2012-01-09T06:53:10.567 に答える
0

私はそれを解決していました。しかし、答えを遅く投稿します。ListField追加する行があまりないので、使用するという考えを捨てました。ListFieldだから私はちょうど私が使用したのではなく、小さなトリックを使用しただけでHorizontalFieldManager、そのように見えるListので、すべてが正常に機能しています。

乾杯ありがとう:)

于 2012-05-10T03:49:11.173 に答える