Blackberry 设置和删除“聚焦”和“聚焦”按钮的位图
如何在管理器上的一些按钮获得焦点时将位图字段放置在管理器中。我尝试了以下代码,但它不起作用` 当按钮获得焦点时,我需要在Vfm中的按钮旁边添加字段1Blackberry 设置和删除“聚焦”和“聚焦”按钮的位图,blackberry,Blackberry,如何在管理器上的一些按钮获得焦点时将位图字段放置在管理器中。我尝试了以下代码,但它不起作用` 当按钮获得焦点时,我需要在Vfm中的按钮旁边添加字段1 button = new ImgButtonField("res/images/trans.png", Field.FOCUSABLE){ protected void onFocus(int direction) { Vfm.insert(field1, button.getIndex())
button = new ImgButtonField("res/images/trans.png", Field.FOCUSABLE){
protected void onFocus(int direction) {
Vfm.insert(field1, button.getIndex()) ;
super.onFocus(direction);
invalidate();
}
protected void onUnfocus() {
Vfm.delete(field1);
super.onUnfocus();
invalidate();
}
};
尝试使用add而不是insert,这是我尝试过的示例代码
ButtonField button,button1;
LabelField field1;
VerticalFieldManager vfm;
public MyScreen()
{
// Set the displayed title of the screen
setTitle("MyTitle");
vfm=new VerticalFieldManager();
field1=new LabelField("Sample");
button=new ButtonField("Sample"){
protected void onFocus(int direction) {
vfm.add(field1);
super.onFocus(direction);
invalidate();
}
protected void onUnfocus() {
vfm.delete(field1);
super.onUnfocus();
invalidate();
}
};
button1=new ButtonField("Sampl1");
this.add(button1);
this.add(button);
this.add(vfm);
}
问候
Rakesh Shankar.P尝试在manager中放置一个作为占位符。空字段将不可见。聚焦时,可以将该空字段替换为field1
NullField myNullField = new NullField();
button = new ImgButtonField("res/images/trans.png", Field.FOCUSABLE){
protected void onFocus(int direction) {
Vfm.replace(myNullField, field1) ;
super.onFocus(direction);
invalidate();
}
protected void onUnfocus() {
Vfm.replace(field1, myNullField);
super.onUnfocus();
invalidate();
}
};
//add fields to Vfm, including the myNullField placeholder.