Editfield strange height

In my application, I have 2 types of edit fields. One of them behaves as a single-line edit field, the other behaves as a multi-line edit field (editarea). On this screen, I have one title, one edit box and one edit area. When I enter text in editfield , it will copy the text and cursor. But when you enter some text in editarea , which includes the tail character (y, g, q, p), editarea height changes, and editfield acts normally. If I do not enter tail characters, this will not change.

Here is my editarea class:

 public class EditAreaField extends HorizontalFieldManager{ private net.rim.device.api.ui.component.EditField editArea; public EditAreaField (){ // some code; editArea.setPadding(25, 10, 0, 10); } public int getPreferredHeight() { int height = Math.max(editArea.getHeight(), textFont.getHeight()); return height + editArea.getPaddingTop(); } } 

label1 → editfield

label2 → editarea

enter image description hereenter image description here

+7
source share
2 answers

this is because you resize using

  int height = Math.max(editArea.getHeight(), textFont.getHeight()); 

instead try to give some fixed height. eg

  height= Graphics.getScreenHeight()/5; 

or you can also use setExtent inside manager subexpression method

  protected void sublayout(int maxWidth, int maxHeight) { layoutChild(_editField, _editField.getPreferredWidth(), _editField.getPreferredHeight()); setPositionChild(_editField, xpos,ypos); setExtent(preferredHeight,preferredWidth); } 

I think it will work. Please let me know

+1
source

About the cursor picture - you redefined drawFocus or / and onFocus or / and onUnfocus and did not redraw properly.

+1
source

All Articles