Спасибо, ребята, я получил одно прекрасное решение от Blackberry Journal.
public class ScrollingSearchBox extends HorizontalFieldManager
{
private int managerWidth;
private int managerHeight;
public ScrollingSearchBox()
{
super(Manager.NO_HORIZONTAL_SCROLL);
searchEdit = new BasicEditField(){
public int getPreferredHeight()
{
return ret;
}
public int getPreferredWidth()
{
return ret;
}
public void paint(Graphics g)
{
getManager().invalidate();
super.paint(g);
}
};
HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL)
{
public void sublayout(int width, int height)
{
if (managerWidth == 0) {
managerWidth = searchEdit.getPreferredWidth();
}
if (managerHeight == 0) {
managerHeight = searchEdit.getPreferredHeight();
}
super.sublayout(managerWidth, managerHeight);
setExtent(managerWidth,managerHeight);
}
public void paint(Graphics g) {
super.paint(g);
}
};
searchEdit.setMaxSize(70);
hfm.add(searchEdit);
add(hfm);
}
public int getPreferredHeight()
{
int ret = 0;
return ret;
}
protected void sublayout(int maxWidth, int maxHeight)
{
int currX = 0;
int currY = 0;
Field currField;
currField = this.getField(0);
switch (ScreenConfig.getInstance().getScreen())
{
case ScreenConfig.SCREEN_320_240:
currX = 5;
currY = 3;
break;
case ScreenConfig.SCREEN_480_360:
case ScreenConfig.SCREEN_480_320:
currX = 5;
currY = 1;
break;
}
this.setPositionChild(currField, currX, currY);
this.layoutChild(currField, currField.getPreferredWidth(),
currField.getPreferredHeight());
setExtent(this.getPreferredWidth(), this.getPreferredHeight());
}
protected void paint(Graphics graphics)
{
super.paint(graphics);
graphics.drawRect(0, 0, this.getPreferredWidth(), this.getPreferredHeight());
}
}
Я даю это, чтобы оно могло помочь другим.
Продолжайте делиться своими кодами.
Спасибо.