2011-11-18 7 views
0

BlackBerryのListField行の背景として垂直グラデーションを表示したいとします。私はこれを達成するためにshadedFillPath機能を使用しますが、失敗している:BlackberryのListFieldItemへの垂直グラデーション

int[] cols = new int[]{0xFFFFFF, 0xEEEEEE,0xEEEEEE,0XDDDDDD }; 
int[] xInds = new int[]{0, Display.getWidth(), Display.getWidth(), 0}; 
int[] yInds = new int[]{focusRect.y, focusRect.y,  
this.getRowHeight()+focusRect.y,this.getRowHeight()+focusRect.y}; 
graphics.drawShadedFilledPath(xInds, yInds,null, cols, null); 

答えて

1

この

 int[] X_PTS = { 0, getPreferredWidth(),getPreferredWidth(),0};   
     int[] Y_PTS = { 0,0, getPreferredHeight(),getPreferredHeight()};   
     int[] drawColors = { Colors.CategoryFocusGradientStart, Colors.CategoryFocusGradientStart, 
          Colors.CategoryFocusGradientEnd, Colors.CategoryFocusGradientEnd };   
     try {    
      g.drawShadedFilledPath(X_PTS, Y_PTS, null, drawColors, null);   
     } catch (IllegalArgumentException e) { 
      Log.Error(e,this,"Bad arguments."); 
     } 
0

そのないの@ rfsk2010の答えを試みるが、ほぼ(あなたは0のyのことを変更する必要があります):

中に、:

public void drawListRow(ListField listField, Graphics graphics,int index, int y, int width) 

これを行います。

int[] X_PTS = { 0, getPreferredWidth(),getPreferredWidth(),0};   
int[] Y_PTS = { y, y, getPreferredHeight(),getPreferredHeight()};   
int[] drawColors = { Colors.CategoryFocusGradientStart, Colors.CategoryFocusGradientStart, 
        Colors.CategoryFocusGradientEnd, Colors.CategoryFocusGradientEnd };   
try {    
    graphics.drawShadedFilledPath(X_PTS, Y_PTS, null, drawColors, null);   
} catch (IllegalArgumentException e) { 
    Log.Error(e,this,"Bad arguments."); 
} 
関連する問題