Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 14
Registered: ‎08-04-2010
My Device: 9700
Accepted Solution

Customize EditField increase row height

Hello,

 

I need to customize the EditField. Mainly, the visible rows should increase instead of only one row initially, and further increase on runtime if more text is added. OR has a vertical scroll. Whatever I do, the EditField displays only the first line, only increases after text goes in the 2nd line.

 

I've been searching all over the net and these forums to get some clue, but nothing works for me.

 

Please help!

 

Thank you!

 

Note: API version I need to use is 4.6

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Customize EditField increase row height

Try USE_ALL_HEIGHT style bit in your new EditField(...) call.  Make sure you limit the size of the Manager of this field.

 

Also, take a look at this article:

TextBoxField revisited

 

The code in the article can be further simplified in versions 4.6+.  You have all the setBorder() possibilities there.  Feel free to experiment.  Be sure to read the comment as well - it has some additional ideas.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 14
Registered: ‎08-04-2010
My Device: 9700

Re: Customize EditField increase row height

Thanks arkadyz

 

 

 

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Customize EditField increase row height

Don't use that old article - seriously!  The problems in it are what prompted me to create my "TextBoxField revisited" in the first place!  Look here:

    editField = new EditField(){
      public void paint(Graphics g) {
      getManager().invalidate();
      super.paint(g);
    }
  };

 

 

The highlighted code will cause the whole Manager to be repainted, which will call paint on each child, including this one! Then its paint() is called again, which invalidates the Manager again, which causes the paint to be called... - hey, you've just created an infinite loop!

 

Besides, the border there will be painted right where the text is, causing it to "stick" to some letters - also not a good idea.  That is why I went through the trouble of laying out the inner vertical field manager with smaller size and positioning it at (1,1) rather than (0,0).

 

Please, take a look at the differences and think them through - I wrote my article for a reason...

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Highlighted
Contributor
Posts: 14
Registered: ‎08-04-2010
My Device: 9700

Re: Customize EditField increase row height

Ohh!!! Thanks for clarifying, it makes sense. I'll modify my code accordingly....

(dunno why I didn't get an email for your reply, just saw it)

 

Thanks again!