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
tunde011
Posts: 17
Registered: ‎04-09-2012
My Device: BB9900
My Carrier: 02
Accepted Solution

Autogrow editfield to a certain height without words hidden

CustomEditField wjroke = new CustomEditField(){

 public int getPreferredHeight(){
   int h = Font.getDefault().getHeight()* 3; 
   //setting the height of edit field as 3 rows
  return h;
 }

 public void layout (int width, int height){

   super.layout (width, height);

   if (getExtent().height < getPreferredHeight()){
       setExtent (width, getPreferredHeight());
   }
 }
};

 Tha above code autogrows a custom edit field, but I will like it to stop after a particular height (let's say 20 ) has been reached. I tried by putting  this after

else{
  setExtent(width, 20);
} 

This sort of works, but when it gets to the set height  it hides the words.

 

I want to autogrow the editfield but stop at a certain height, without the words hidden away because of the height restriction. Any help will do

 

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Autogrow editfield to a certain height without words hidden

"I want to autogrow the editfield but stop at a certain height, without the words hidden away"

You mean you want to stop the user entering input when the field has reached a certain size?

 

I suspect the number of characters that the user can enter will depend on the phone, the language, the case and the font used, so will vary from user to use.  To me that does not sound like a good user experience.

 

Perhaps you want to restrict the space that the Field takes up on the screen, but allow the user to scroll their text within that space.  If so, this KB article should help:

http://supportforums.blackberry.com/t5/Java-Development/TextBoxField-revisited/ta-p/548410

Please use plain text.