Note that there are some explanatory texts on larger screens.

plurals
  1. POblackberry lazyloading in clumsy layout
    primarykey
    data
    text
    <p>I am using a customlistfield by extending VerticalFieldManager, and for the row I am usingf another CustoRowManager that extends Manager. The CustomRowManager has 2 TextField and a BitmapField . This list is implemented for a live xml feed. For loading the bitmapfield I am displaying placeholders which is then replaced by the actual image from background thread. I am not able to figure out how I should replace place holders with the bitmapfield. using invalidate() is one option, but on which element I should perform it.</p> <pre><code>public class CustomList extends VerticalFieldManager{ private int totalHeight = 0; private int screenHeight = 0; private int scrollPosition = 0; protected void sublayout(int width, int height) { width = 480; height = 230; super.sublayout(width,height); setExtent(width, height); } protected boolean navigationClick(int status, int time) { int index; System.out.println("CLICKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); if ((status &amp; KeypadListener.STATUS_FOUR_WAY) == KeypadListener.STATUS_FOUR_WAY) { index = this.getFieldWithFocusIndex(); UiApplication.getUiApplication().pushScreen(new TopNewsScreen(_vec, index)); } return true; } Bitmap _bmp = null; BitmapField _bmF = null; Object _Obj = null; TopNews _topNews = null; String _headStr = null, _metaStr = null; CustTextField _headNews = null, _metaData = null; CustomRow _custRow = null; Vector _vec; public CustomList(Vector _vec,long _property) { super(_property); this._vec = new Vector(); this._vec = _vec; int _size = _vec.size(); int i ; for(i = 0; i &lt;_size; i++) { _headStr = new String(); _metaStr = new String(); _bmp = Bitmap.getBitmapResource("img/1.jpg"); _bmF = new BitmapField(_bmp); _topNews = (TopNews)_vec.elementAt(i); _headStr = _topNews.getHeadline(); _metaStr = _topNews.getMetaData(); int _newsLeng = _headStr.length(), alert = 0; if(_newsLeng &lt;= 35) { alert = 0; }else if(_newsLeng&gt;35&amp;&amp;_newsLeng&lt;=70) { alert = 1; }else { alert = 2; _headStr = this.truncate(_headStr,70); } _custRow = new CustomRow(alert); _headNews = new CustTextField(_headStr,25,0x05235b,TextField.NON_FOCUSABLE); _metaData = new CustTextField(_metaStr,15,0x666666,TextField.NON_FOCUSABLE); _custRow.add(_headNews); _custRow.add(_metaData); _custRow.add(_bmF); super.add(_custRow); } } String truncate(String value, int length) { if (value != null &amp;&amp; value.length() &gt; length) value = value.substring(0, length); return value; } } class CustomRow extends Manager implements FocusChangeListener{ private int _headLeng; private NullField _focus = null; CustomRow(int _headLeng) { super(Manager.FOCUSABLE| Manager.NO_HORIZONTAL_SCROLL |Manager.NO_VERTICAL_SCROLL); this._headLeng = _headLeng; _focus = new NullField(NullField.FOCUSABLE); _focus.setFocusListener(CustomRow.this); this.add(_focus); } protected void sublayout(int width, int height) { if(_headLeng==0) { layoutChild(getField(0),0,0); setPositionChild(getField(0),0 , 0); layoutChild(getField(1),360,20); setPositionChild(getField(1),10 , 10); layoutChild(getField(2),300, 20); setPositionChild(getField(2), 10, 65); layoutChild(getField(3),90,65); setPositionChild(getField(3), 380, 10); }else { /* layoutChild(getField(0),0,0); setPositionChild(getField(0),0 , 0); layoutChild(getField(1),360,20); setPositionChild(getField(1),10 , 10); layoutChild(getField(2),300, 20); setPositionChild(getField(2), 10, 50); layoutChild(getField(3),90,65); setPositionChild(getField(3), 380, 10); */ layoutChild(getField(0),0,0); setPositionChild(getField(0),0 , 0); layoutChild(getField(1),360,20); setPositionChild(getField(1),10 , 10); layoutChild(getField(2),300, 20); setPositionChild(getField(2), 10, 65); layoutChild(getField(3),90,65); setPositionChild(getField(3), 380, 10); } height = 80; width = 480; setExtent(width, height); } protected void paint(Graphics graphics) { graphics.setColor(Color.GRAY); graphics.drawLine(10, 79, Display.getWidth()-10, 79); super.paint(graphics); } public void focusChanged(Field field, int eventType) { // TODO Auto-generated method stub this.getManager().invalidate(); } protected void paintBackground(Graphics g) { int prevBg = g.getBackgroundColor(); if (_focus.isFocus()) { g.setBackgroundColor(Color.LIGHTBLUE); } else { g.setBackgroundColor(Color.WHITE); } g.clear(); g.setBackgroundColor(prevBg); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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