我创建了一个customUi类,我创建了3个fiels作为1个标签和2个按钮文件....
所以我创建了customui并传递了文件名......
喜欢
public class CustomTextField extends Manager {
Field field ;
//passing 3 names to the construcor
protected void sublayout(int width, int height) {
// TODO Auto-generated method stub
int fieldCount = getFieldCount();
int screenWidth = Display.getWidth();
int yOffset =0;
for(int i=0; i<fieldCount; i++)
{
field= getField(i);
layoutChild(field, screenWidth, 100 );
setPositionChild(field, (screenWidth-field.getWidth())>>1, yOffset);
yOffset += field.getHeight()+5;
}
setExtent(screenWidth, yOffset);
}
protected void paintBackground(Graphics g) {
if(field.isFocus())
{
//g.setBackgroundColor(Color.ALICEBLUE);
int oldColor = g.getColor();
g.setColor(Color.DARKBLUE);
g.drawRoundRect(0, 0, getWidth(), getHeight(), Graphics.ALL_ROUNDED_RECT_CORNERS, 60, 60);
g.setColor(oldColor);
}
}
答案 0 :(得分:1)
不要覆盖经理内部的paintBackground(Graphics g)
。在子字段类中重写它。儿童领域的责任是如何呈现其聚焦状态。