我在屏幕上有3个经理 h1 h2 bmpf=new BitmapField

添加了这样的

backgroundmanager.add(h1)
backgroundmanager.add(bmpf)
backgroundmanager.add(h2)

add(background manager);

protected boolesn navigationClick()
{
int index1 = h1.getFieldWithFocusIndex();
int index2 = h2.getFieldWithFocusIndex();
return true;
}

刈i获得重点指数的所有focussable领域在管理人员h1和h2

但我不能获得指数的bitnmapfield焦点 我需要执行一些代码在它的点击

该怎么做

有帮助吗?

解决方案 2

以及我设置位图字段的程度,并放置在一个水平场管理的位图字段和它的工作

class myscreen extends MainScreen
 {
    BitmapField mBitmapField;

    hm = new HorizontalFieldManager();
    hm.add(mBitmapField)

    protected boolean navigationClick(int status, int time)
   {       
        if (hm.getFieldWithFocusIndex==0) 
        {
             Dialog.inform("Image focussed");
        }
        return true;
    }
}

我不明白为什么前面相同的逻辑不工作!!!!!!!!!!

可以是bcoz BitmapField的程度的

其他提示

为什么你需要BitmapField指数?也许它会更容易宣布BitmapField作为一个屏幕的会员吗?如果你还需要索引,呼叫 getIndex() 从领域。

class Scr extends MainScreen {
    BitmapField mBitmapField;

    protected boolean navigationClick(int status, int time) {
        int bmpIndex = mBitmapField.getManager.getFocusedIndex();
        return true;
    }
}

更新 其他有益方法的领域类 getManager():

class Scr extends MainScreen {
    BitmapField mBitmapField;

    protected boolean navigationClick(int status, int time) {
        int index = -1;
        Manager manager = mBitmapField.getManager();
        if (manager != null) {
             index = manager.getFieldWithFocusIndex();
        }
        return true;
    }
}

尝试所以你不需要关心的指标,当用户点击该位图,然后你的代码将运行覆盖内嵌的bitmapField navigationClick和DRAWFOCUS方法。


protected void drawFocus(Graphics graphics, boolean on){
    //the simplies way to draw a rectangle and this will be the focus
}

protected boolean navigationClick(int status, int time) { //write here your code what you want to run the user clicks to the bitmap return true; }

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top