blackberry中的自定义字段焦点
我在其中创建了一个customUi类,我创建了3个区域作为1个标签和两个按钮文件 所以我正在创建customui并传递文件名 像blackberry中的自定义字段焦点,blackberry,focus,Blackberry,Focus,我在其中创建了一个customUi类,我创建了3个区域作为1个标签和两个按钮文件 所以我正在创建customui并传递文件名 像 公共类CustomTextField扩展管理器{ 场域; //将3个名称传递给构造函数 受保护的空位子布局(整数宽度、整数高度){ //TODO自动生成的方法存根 int fieldCount=getFieldCount(); int screenWidth=Display.getWidth(); int-yOffset=0; 对于(int i=0;i>1,yOffs
公共类CustomTextField扩展管理器{
场域;
//将3个名称传递给构造函数
受保护的空位子布局(整数宽度、整数高度){
//TODO自动生成的方法存根
int fieldCount=getFieldCount();
int screenWidth=Display.getWidth();
int-yOffset=0;
对于(int i=0;i>1,yOffset);
yOffset+=field.getHeight()+5;
}
setExtent(屏幕宽度,yOffset);
}
受保护的空白油漆背景(图形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);
}
}
不要覆盖管理器内部的画图背景(图形g)
。在子字段类中重写它。如何显示其焦点状态是子字段的责任。CustomTextField(字符串名称、字符串名称、字符串名称){添加三个字段}在主屏幕类中,我创建了这个类的三个CustomField…但我在选择每个字段时遇到了焦点问题…-1。这是一个写得很差的问题。至少,第一条评论应该转移到问题中,这样实际上就有一个问题被问到了。但总的来说,它需要一系列的清理工作。
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);
}
}