Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom Listfield doesn't draw correctly
    text
    copied!<p>I added a custom listfield component using BSimpleTable which I got from here : <a href="http://javaandjava.blogspot.com/2010/02/simple-table-component-for-blackberry.html" rel="nofollow">http://javaandjava.blogspot.com/2010/02/simple-table-component-for-blackberry.html</a> Unfortunately the component doesn't support right alignment for the fields inside it, so I tried to added it by modifying the code, like this :</p> <pre><code>public class BSimpleRowRenderer extends Manager{ private int[] colWidthPercents; private int[] cellFrontPaddings; private int preferredHeight; public BSimpleRowRenderer(long style,Field[] rowContents,int preferredHeight, int[] colWidthPercents,int[] cellFrontPaddings){ super(style); for (int col = 0; col &lt; rowContents.length; col++) { add(rowContents[col]); } this.colWidthPercents = new int[rowContents.length]; for(int i=0;i&lt;colWidthPercents.length;i++){ this.colWidthPercents[i] = colWidthPercents[i]; } this.cellFrontPaddings = new int[rowContents.length]; for(int i=0;i&lt;cellFrontPaddings.length;i++){ this.cellFrontPaddings[i] = cellFrontPaddings[i]; } this.preferredHeight = preferredHeight; } protected void sublayout(int width, int height) { int x=0; int totalWidth = Display.getWidth(); for (int col = 0; col &lt; getFieldCount(); col++) { // Set the size and position of the current cell. Field curCellField = getField(col); XYPoint offset = calcAlignmentOffset(curCellField, Math.max(0,colWidthPercents[col]*totalWidth/100), Math.max(0, getPreferredHeight())); layoutChild(curCellField, width-x,getPreferredHeight()); setPositionChild(curCellField, x+offset.x, 0); x+=(int)Math.floor((colWidthPercents[col]*totalWidth)/100); } setExtent(Display.getWidth(), getPreferredHeight()); } public void drawRow(Graphics g, int x, int y, int width, int height) { layout(width, height); setPosition(x, y); g.pushRegion(getExtent()); subpaint(g); g.popContext(); } public int getPreferredWidth() { return Display.getWidth(); } public int getPreferredHeight() { return preferredHeight; } private XYPoint calcAlignmentOffset(Field field, int width, int height) { XYPoint offset = new XYPoint(0, 0); long fieldStyle = field.getStyle(); long field_x_style = fieldStyle &amp; Field.FIELD_HALIGN_MASK; if (field_x_style == Field.FIELD_RIGHT){ offset.x = width - field.getExtent().width; } else if (field_x_style == Field.FIELD_HCENTER){ offset.x = (width - field.getExtent().width) / 2; } long field_y_style = fieldStyle &amp; Field.FIELD_VALIGN_MASK; if (field_y_style == Field.FIELD_BOTTOM){ offset.y = height - field.getExtent().height; } else if (field_y_style == Field.FIELD_VCENTER){ offset.y = (height - field.getExtent().height) / 2; } return offset; } </code></pre> <p>}</p> <p>The problem is, the right alignment is only working for fields inside highlighted row or row which have been highlighted. I wonder where have I done wrong or missed in the above code. I'm in real desperate now as to any modification doesn't reflect what I want to accomplish.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload