Blackberry 点击黑莓手机上的按钮
如何使用blackberry api单击按钮字段?我想模仿用户按下按钮的样子。使用Blackberry 点击黑莓手机上的按钮,blackberry,java-me,Blackberry,Java Me,如何使用blackberry api单击按钮字段?我想模仿用户按下按钮的样子。使用EventInjector.NavigationEvent如下: EventInjector.invokeEvent(new EventInjector.NavigationEvent(EventInjector.Navig ationEvent.NAVIGATION_CLICK, 0, 0, 0)); 像这样使用EventInjector.NavigationEvent: EventInjector.invok
EventInjector.NavigationEvent
如下:
EventInjector.invokeEvent(new EventInjector.NavigationEvent(EventInjector.Navig ationEvent.NAVIGATION_CLICK, 0, 0, 0));
像这样使用
EventInjector.NavigationEvent
:
EventInjector.invokeEvent(new EventInjector.NavigationEvent(EventInjector.Navig ationEvent.NAVIGATION_CLICK, 0, 0, 0));
假设您有以下代码(取自BB API文档):
然后,您可以通过调用
按钮字段
的字段更改通知(int-context)
方法,以编程方式模拟单击。请注意,您可以通过检查字段更改(字段字段,int-context)
中的上下文来区分正常/实际点击与编程点击。它与您在fieldchangennotify(int-context)
中传递的上下文相同,假设您有此代码(取自BB API文档):
然后,您可以通过调用按钮字段
的字段更改通知(int-context)
方法,以编程方式模拟单击。请注意,您可以通过检查字段更改(字段字段,int-context)
中的上下文来区分正常/实际点击与编程点击。这与您在fieldchangennotify(int context)
中传递的上下文相同,谢谢,但我如何将其链接到特定的按钮字段?谢谢,但我如何将其链接到特定的按钮字段?我不确定这比Arhimed之前给出的答案提供了什么。完美。。。不知道是谁投了反对票。。请在你否决投票前核实。我不确定这比Arhimed之前给出的答案提供了什么。太好了。。。不知道是谁投了反对票。。请在投票前核实一下。
ButtonField buttonField = new ButtonField("Test Button" ,ButtonField.CONSUME_CLICK);
buttonField.setChangeListener(new FieldChangeListener()
{
public void fieldChanged(Field field, int context)
{
Dialog.alert("Test Button Clicked");
}
});