2011-08-11 9 views
0

私はBB devの初心者です。私はCustomListFieldを作成し、行をクリックすると、この行の背景色が変更され、新しい画面が表示されなければなりません(完了です)。ナビゲーション後にListFieldの行の色の背景を変更する方法をクリックします。

これを行うには手伝ってください。 THX以下

コードです:

protected boolean navigationClick(int status, int time) 
     {Field field = this.getLeafFieldWithFocus(); 

     if(field instanceof ListField) 
     { 
     // listValues is String[] where you store your list elements. 
     // listField is the ListField instance you are using 
      UiApplication.getUiApplication().pushScreen(new ReadMsgScreen()); 

      int index= getIndex(); 
      if(index== this.getSelectedIndex()) 
      { 
       **// I think the code to change the row's background color must be set here!** 

      } 

      return true; 
     } 

     return super.navigationClick(status, time); 
    } 

答えて

0

ブラックベリーでpaint()メソッドonerride以下のコードを示したよう..

_specialNumbers = new LabelField(Constants.SPECIAL_NUMBERS,LabelField.USE_ALL_WIDTH) { 
      protected void paintBackground(Graphics arg0) { 
       int color = arg0.getBackgroundColor(); 
       arg0.setBackgroundColor(Color.LIGHTGREY); 
       arg0.clear(); 
       arg0.setBackgroundColor(color); 
      } 
     }; 
+0

ListField行のpaint()メソッドを呼び出す必要があります。 'int index = getIndex(); 場合(インデックス== this.getSelectedIndex()){ **私はここで設定する必要があり、行の背景色を変更するコードを考えて// ** !}私はpaint()メソッドをオーバーライドすることを試みた ' – Manel

+0

: 'TableRowManager ele_row =新しいTableRowManager() \t \t \t { \t \t \t \t保護ボイドペイント(グラフィックスグラフィック){ \t \t \t \t \t無効()。 \t \t \t \t \t graphics.setBackgroundColor(Color.RED); \t \t \t \t \t super.paint(graphics); \t \t \t \t} \t \t \t}それでもまだ動かない!!誰でもリストフィールドの行の背景色を変更する方法について考えていますか? – Manel

+0

この問題の解決策は 'g.setBackgroundColor(0x33CCFF);を追加することです。 'drawRow(Graphics g、int x、int y、int width、int height)'メソッドの直前の 'g paint.graph'(g);メソッドの直前のメソッドです。' public void drawRow(Graphics g、int x、int y、int width、int height){layout(width、height); setPosition(x、y); g.pushRegion(getExtent()); g.setBackgroundColor(0x33CCFF); g.clear(); g.setColor(Color.BLACK);サブペイント(g); – Manel

1

使用このそれは間違いなく動作します...

int tmpcolor = graphics.getColor(); 
graphics.setColor(Color.CYAN); 
graphics.fillRect(0, y, width, getRowHeight()); 
graphics.setColor(tmpcolor); 

ありがとう...

0

CustomListFieldのListFieldCallbackのdrawListRow()メソッドでは、選択された行が異なって描画され、Transitionを呼び出して他の画面をゆっくり表示します。

関連する問題