【发布时间】:2012-03-27 05:29:24
【问题描述】:
我在屏幕的底部栏中放置了一个按钮。底栏基本上是一个带有背景图像的水平字段管理器。现在这个按钮(基本上是一个继续按钮)用于移动到下一个屏幕。但如果我在管理器中和按钮外单击,它将进入下一个屏幕。所以点击事件对总经理起作用,下面是代码:
HorizontalFieldManager hfmBtn = new HorizontalFieldManager(Field.FIELD_BOTTOM)
{
protected void sublayout(int nMaxWidth, int nMaxHeight)
{
height = Bitmap.getBitmapResource("buttom_bar.png").getHeight();
super.sublayout(nMaxWidth, nMaxHeight);
setExtent(getPreferredWidth(), getPreferredHeight());
}
public int getPreferredHeight()
{
return height;
}
public int getPreferredWidth()
{
return screenWidth;
}
};
hfmBtn.setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("buttom_bar.png")));
btnContinue = new CustomButtonImageField("Continue", Bitmap.getBitmapResource("button_normal.png"), Bitmap.getBitmapResource("button_hover.png"),Field.FIELD_VCENTER);
btnContinue.setChangeListener(this);
btnContinue.setMargin(10, 0, 0, screenWidth/3);
hfmBtn.add(btnContinue);
add(hfmBtn);
这里是点击事件:
public void fieldChanged(Field field, int context)
{
if(field == btnContinue)
{
UiApplication.getUiApplication().pushScreen(new SendListScreen(platformContext,strItemList));
}
}
请帮帮我。我正在用 BB Bold 9790 进行测试。
【问题讨论】:
-
没有其他领域有焦点。所以默认焦点将在按钮中。
-
一旦您进入按钮焦点,当您单击其他区域时,您将获得该按钮单击事件。但是当你专注于其他领域时,你不会遇到这个问题。所以添加一个 Focusable 字段进行测试,而不是尝试点击按钮 ..
标签: blackberry