Blackberry Storm - сосредоточить внимание на растровом поле - PullRequest
0 голосов
/ 10 марта 2010

на моем экране 3 менеджера h1 h2 bmpf = новый 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;
}

Как получить индекс фокуса для всех фокусируемых полей в менеджерах h1 и h2

но я не могу получить индекс поля bitnmap в фокусе мне нужно выполнить какой-то код по его нажатию

что делать

Ответы [ 3 ]

1 голос
/ 10 марта 2010

Зачем вам нужен индекс 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;
    }
}
0 голосов
/ 12 марта 2010

Попробуйте переопределить встроенный метод bitmapField navigationClick и drawFocus, чтобы вам не нужно было заботиться об индексе, когда пользователь нажимает на растровое изображение, тогда ваш код будет выполняться.

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

<p>protected boolean navigationClick(int status, int time) 
{
    //write here your code what you want to run the user clicks to the bitmap
    return true;
}
0 голосов
/ 12 марта 2010

хорошо, я установил экстент поля растрового изображения и поместил поле растрового изображения в горизонтальный менеджер полей, и это сработало

в

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

...