Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>by default ... list field provides the focus on a single row as a whole....and not to the single field on a row(as u told that u want to add three fields....buttons, textfield, textfield).</p> <p>so i want to know why do u want to add buttons and two separate text-fields in a single row... I think its not easy if u want to get focus only on button OR only on a text-field....in a single row of a list field.</p> <p>by the way... here is the sample code........ how u create three fields in a single row of list field...</p> <p>just call the constructor of this list-field class in ur main screen's class and add it like.....</p> <pre><code>DetailListField _listField = new DetailListField(); add(_listField); </code></pre> <p>DetailListField class - </p> <pre><code>class DetailListField extends ListField implements ListFieldCallback { private Vector rows; private Font font; public DetailListField() { this(0, ListField.USE_ALL_WIDTH | DrawStyle.LEFT); } public DetailListField(int numRows, long style) { super(0, style); try { rows = new Vector(); font = Font.getDefault().derive(Font.PLAIN, 7, Ui.UNITS_pt); setRowHeight(-2); setCallback(this); for (int x = 0 ; x &lt; 5 ; x++) { TableRowManager row = new TableRowManager(); // button, textfield, textfield ButtonField _btn = new ButtonField("Button", ButtonField.CONSUME_CLICK); _btn.setBorder(VISUAL_STATE_NORMAL, BorderFactory.createSimpleBorder(new XYEdges(1,1,1,1), new XYEdges(0x557788, 0xAA22BB, 0x557788, 0xAA22BB), Border.STYLE_SOLID)); row.add(_btn); BasicEditField _basicEdit1 = new BasicEditField(BasicEditField.EDITABLE | BasicEditField.FILTER_DEFAULT); _basicEdit1.setBorder(VISUAL_STATE_NORMAL, BorderFactory.createSimpleBorder(new XYEdges(2,2,2,2), new XYEdges(0x557788, 0xAA22BB, 0x557788, 0xAA22BB), Border.STYLE_SOLID)); row.add(_basicEdit1); BasicEditField _basicEdit2 = new BasicEditField(BasicEditField.EDITABLE | BasicEditField.FILTER_DEFAULT); _basicEdit2.setBorder(VISUAL_STATE_NORMAL, BorderFactory.createSimpleBorder(new XYEdges(2,2,2,2), new XYEdges(0x994422, 0xAA22BB, 0x994422, 0xAA22BB), Border.STYLE_SOLID)); row.add(_basicEdit2); // add id to the vector. rows.addElement(row); // returnData[x][0]); // call draw list row // then call constructor of manager class } setSize(rows.size()); invalidate(); } catch(Exception e) { } } public void drawListRow(ListField list, Graphics g, int index, int y, int width) { try { DetailListField dl = (DetailListField)list; TableRowManager rowManager = (TableRowManager)dl.rows.elementAt(index); rowManager.drawRow(g, 0, y, width, list.getRowHeight()); } catch(Exception e) { } } protected boolean keyChar(char key, int status, int time) { if (key == Characters.ENTER) { return true; // We've consumed the event. } else if(key == Characters.ESCAPE) { return true; } return super.keyChar(key, status, time); } protected boolean navigationClick(int status, int time) { try { // use below method if want to get label value from manager. final int index = this.getSelectedIndex(); if(index &gt;= 0) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Dialog.alert("Selected index number : " + (index + 1)); } }); } } catch (final Exception e) { } return true; } public Object get(ListField listField, int index) { // TODO Auto-generated method stub return rows.elementAt(index); } public int getPreferredWidth(ListField listField) { // TODO Auto-generated method stub return 0; } public int indexOfList(ListField listField, String prefix, int start) { // TODO Auto-generated method stub return rows.indexOf(prefix, start); } /** * MANAGER CLASS */ private class TableRowManager extends Manager { int _height = 0, _width = 0; int yPos = 0; public TableRowManager() { super(0); } // Causes the fields within this row manager to be layed out then // painted. public void drawRow(Graphics g, int x, int y, int width, int height) { try { _height = height; _width = getPreferredWidth(); yPos = y; // Arrange the cell fields within this row manager. // set the size and position of each field. layout(_width, _height); // Place this row manager within its enclosing list. setPosition(x, y); // Apply a translating/clipping transformation to the graphics // context so that this row paints in the right area. g.pushRegion(getExtent()); // Paint this manager's controlled fields. subpaint(g); g.setColor(0x00CACACA); g.drawLine(0, 0, getPreferredWidth(), 0); // Restore the graphics context. g.popContext(); } catch(Exception e) { System.out.println("Exeception : (DetailListField) 4 : " + e.toString()); } } // Arranges this manager's controlled fields from left to right within // the enclosing table's columns. protected void sublayout(int width, int height) { try { // set the bitmap field Field _field0 = getField(0); layoutChild(_field0, (_width/3) - 30 , _height - 20); setPositionChild(_field0, 2, 5); // set the name field Field _field1 = getField(1); _field1.setFont(font); layoutChild(_field1, (_width/3) - 30, _field1.getPreferredHeight()); setPositionChild(_field1, (_width/3) - 30 + 10, 5); Field _field2 = getField(2); _field2.setFont(font); layoutChild(_field2, (_width/3) - 30, _field2.getPreferredHeight()); setPositionChild(_field2, ((_width/3) - 30)*2 + 20, 5); setExtent(_width, _height); } catch(Exception e) { System.out.println("Exeception : (DetailListField) 5 : " + e.toString()); } } // The preferred width of a row is defined by the list renderer. public int getPreferredWidth() { return (Display.getWidth()); } // The preferred height of a row is the "row height" as defined in the // enclosing list. public int getPreferredHeight() { return _height; } } } </code></pre> <p>bt still i dont know how to get focus on single field of a single row...</p>
    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.
    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