Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry 设置和删除“聚焦”和“聚焦”按钮的位图_Blackberry - Fatal编程技术网

Blackberry 设置和删除“聚焦”和“聚焦”按钮的位图

Blackberry 设置和删除“聚焦”和“聚焦”按钮的位图,blackberry,Blackberry,如何在管理器上的一些按钮获得焦点时将位图字段放置在管理器中。我尝试了以下代码,但它不起作用` 当按钮获得焦点时,我需要在Vfm中的按钮旁边添加字段1 button = new ImgButtonField("res/images/trans.png", Field.FOCUSABLE){ protected void onFocus(int direction) { Vfm.insert(field1, button.getIndex())

如何在管理器上的一些按钮获得焦点时将位图字段放置在管理器中。我尝试了以下代码,但它不起作用`

当按钮获得焦点时,我需要在Vfm中的按钮旁边添加字段1

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.