我有一個LabelField whith的風格FOCUSABLE和許多可調焦的Field s之後,我忽略navigationMovement方法LabelField。
問題是:代碼永遠不會輸入navigationMovement的新實現中,但重點通常從LabelField移至下一個Field,而不通過navigationMovement實現!
PS,我也使用調試器來測試,以確保它永遠不會進入它的實現。
爲什麼會發生這種情況,以及如何捕獲FOCUSABLE LabelField的navigationMovement事件?爲什麼navigationMovement for FOCUSABLE LabeField在Blackberry中被繞過?
CODE:
這裏的類:
public abstract class FocusableLabelField extends LabelField {
public boolean isDownUnfocused = false;
public FocusableLabelField(String text) {
super(text, FOCUSABLE);
}
protected void drawFocus(Graphics graphics, boolean on) {
// DO NOTHING, FOCUS IS HANDLED IN PAINT
}
protected void paint(Graphics graphics) {
if(isDownUnfocused == true)
graphics.setColor(0xFFFFFF);
else {
if(isFocus())
graphics.setColor(0xFFFFFF);
else {
graphics.setColor(0x777777);
}
}
super.paint(graphics);
}
protected void onFocus(int direction) {
isDownUnfocused = false;
onFocusing();
super.onFocus(direction);
}
public abstract void onFocusing();
public void redraw() {
invalidate();
}
protected boolean navigationMovement(int dx, int dy, int status, int time) {
//TODO CHECK WHY IT'S NOT ENTERING HERE !
if(dy>0)
isDownUnfocused = true;
invalidate(); // IF REMOVED NO EFFECT WILL BE APPLIED
return super.navigationMovement(dx, dy, status, time);
}
}
這裏就是我如何使用它的屏幕:
FocusableLabelField field = new FocusableLabelField("title") {
public void onFocusing() {
// some logic in the screen is done here ...
}
} ;
你可以發佈你的LabelField子類嗎?至少你正在使用的'navigationMovement()'方法? – Nate 2012-07-10 21:16:56
現在更新了代碼。 – 2012-07-11 09:28:55
這不是你的實際代碼嗎?該代碼甚至沒有編譯。你甚至不給它一個類型(例如'boolean')就聲明'isDownUnfocused',然後用相同的簽名實現兩個方法...'protected void paint(Graphics);'。這不是合法的Java。請發佈您實際使用的代碼,否則很難提供幫助。謝謝。 – Nate 2012-07-11 22:44:39