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

EditField and two objectchoicefields in Horizontalfieldmanager

[ Edited ]

I want to add EditField and 2 objectchoicefields in horizontalfieldmanager. Editfield should have rounded corners. Following is code i have written.

 

hfm = new HorizontalFieldManager();
search_field = new BasicEditField()
{
protected void layout(int width, int height)
{
int w = Display.getWidth()/2-50;
setExtent(w, font.getHeight());
};
protected void paintBackground(Graphics graphics)
{
graphics.setColor(Color.BLACK);
graphics.setBackgroundColor(Color.WHITE);
}
protected void onFocus(int direction)
{
setLabel("");
};
protected void onUnfocus()
{
setLabel("Search");
};
};

hfm_search.setBackground(BackgroundFactory.createLinearGradientBackground(0x00e0e0e0, 0x00e0e0e0, 0x00e0e0e0, 0x00e0e0e0));

search_field.setLabel("Search");
search_field.setFont(font);

XYEdges edge = new XYEdges (5,5,5,5);
search_field.setBorder (BorderFactory.createRoundedBorder (edge, Border.STYLE_SOLID));

search_field.setPadding(5,10,5,10);

hfm_search.add(search_field);

ObjectChoiceField combo1 = new ObjectChoiceField("", str1);
ObjectChoiceField combo2 = new ObjectChoiceField("",str2);

comboShows.setFont(font);
comboPrice.setFont(font);

hfm_search.add(combo1);
hfm_search.add(combo2);

add(hfm_search);

 

My problem is that i am unable to type inside search_field. I set it as Editable still the same thing is happening.

Even i am not able to focues the search_field and other 2 combos, Next to that i want to set backgroundcolor to Horizontalfieldmanager as gray. But search_field's background color should be white. when i set background color like i have set in code search_field's background color also becomes gray. Please someone help.

Developer
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10
My Carrier: Vodafone, Airtel

Re: EditField and two objectchoicefields in Horizontalfieldmanager

[ Edited ]

Use This :

 

search_field = new BasicEditField()
		{
			protected void onFocus(int direction)
			{
				this.setText("");
			};
			protected void onUnfocus()
			{
				this.setText("Search");
			};
		};
		search_field.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
		search_field.setText("Search");

		XYEdges edge = new XYEdges (5,5,5,5);
		search_field.setBorder (BorderFactory.createRoundedBorder (edge, Border.STYLE_SOLID));

		final ObjectChoiceField combo1 = new ObjectChoiceField("", str1);
		final ObjectChoiceField combo2 = new ObjectChoiceField("",str2);
		hfm_search = new HorizontalFieldManager(){
			protected void sublayout(int maxWidth, int maxHeight) {
				setPositionChild(search_field, 10, 5);
				layoutChild(search_field, 150, 50);
				setPositionChild(combo1, 160, 0);
				layoutChild(combo1, 120, 50);
				setPositionChild(combo2, 280, 0);
				layoutChild(combo2, 80, 50);
				setExtent(maxWidth, 50);
			}
		};

		hfm_search.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
		hfm_search.add(search_field);
		hfm_search.add(combo1);
		hfm_search.add(combo2);

		add(hfm_search);

 

 

feel free to press the like button if u like the Post

if this is a solution for u then plz press the Accept as Solution.

 

------------------------------

  Brajesh Sanodiya

 

 

-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: EditField and two objectchoicefields in Horizontalfieldmanager

While I am looking at this new problem, how are you going with the old problems you were working on, like this one:

http://supportforums.blackberry.com/t5/Java-Development/HorizontalFieldManager-Problem/m-p/1869517#M...

 

It is useful for other readers of the forum if you tidy up your old Threads, that makes it better here for everyone. 

 

So let us know how you going with the ones you haven't makrked as solved.  That would be useful thanks.