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
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

EditField problem

[ Edited ]

I have a problem in editfield. I want to add  small search image and then a text in editfield. If i add text in constructor,image get overlaps with text.Here is the code:

 

editField=new EditField("Search:","")
{
protected void paintBackground(Graphics graphics)
{
graphics.setColor(Color.BLACK);

graphics.drawRoundRect(0, 0, getWidth(), getHeight(), 15, 15);
graphics.drawBitmap(0, 5, getWidth(), getHeight(), img_search, 0, 0);
}
protected void layout(int width, int height)
{
int w = Display.getWidth();
int h = 35;
super.layout( w, h);
setExtent( w, h);
}
};

 

If i use drawText() then the input which i am going to type in editfield is overlaps with image and text.Here is the code:

 

editField=new EditField()
{
protected void paintBackground(Graphics graphics)
{
graphics.setColor(Color.BLACK);

graphic.drawText("Search",25,15);

graphics.drawRoundRect(0, 0, getWidth(), getHeight(), 15, 15); 
graphics.drawBitmap(0, 5, getWidth(), getHeight(), img_search, 0, 0);
}
protected void layout(int width, int height)
{
int w = Display.getWidth();
int h = 35; 
super.layout( w, h); 
setExtent( w, h);

};

 

please help someone.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: EditField problem

use a separate bitmapfield
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

Re: EditField problem

If i use separate bitmapfield i am unable to display  icon and text in roundrect which is i am drawing for the editfield.

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: EditField problem

you can do that by using a manager with a border, for example.

if you really want to use a custom field: use a custom field, no not overwrite editfield, it has a lot of internal processing you can get problems with.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
JoVinz
Posts: 255
Registered: ‎05-03-2012
My Device: 9930

Re: EditField problem

[ Edited ]

I used HorizontalFieldManager with border as per u said. Below that i have a listfield. When i scroll through a list it gives weird display :smileysad:

Lines are displayed in listField content both in simulator and in device.