08-28-2012 03:43 AM - edited 08-28-2012 03:45 AM
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.createL
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.
08-28-2012 06:47 AM - edited 08-28-2012 06:50 AM
Use This :
search_field = new BasicEditField()
{
protected void onFocus(int direction)
{
this.setText("");
};
protected void onUnfocus()
{
this.setText("Search");
};
};
search_field.setBackground(BackgroundFactory.creat eSolidBackground(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.createS olidBackground(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
08-28-2012 06:56 AM
While I am looking at this new problem, how are you going with the old problems you were working on, like this one:
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.