Blackberry 异常:if(不绑定)dialog.close();
如果触摸事件发生在对话框字段外,我是否可以在对话框中关闭自身?我可以在相反的情况下很好地关闭它,如下代码所示:Blackberry 异常:if(不绑定)dialog.close();,blackberry,Blackberry,如果触摸事件发生在对话框字段外,我是否可以在对话框中关闭自身?我可以在相反的情况下很好地关闭它,如下代码所示: protected boolean touchEvent(TouchEvent message) { int x = message.getX( 1 ); int y = message.getY( 1 ); if( x < 0 || y < 0 || x > getExtent().width || y > getExtent().he
protected boolean touchEvent(TouchEvent message)
{
int x = message.getX( 1 );
int y = message.getY( 1 );
if( x < 0 || y < 0 || x > getExtent().width || y > getExtent().height ) {
// Outside the field
// close();//? can't be closed properly
return false;
}
switch( message.getEvent() ) {
case TouchEvent.UNCLICK:
close();//? can be closed properly
return true;
}
return super.touchEvent( message );
}
试试这个。
与其写,不如写这个。希望它能起作用
UiApplication.getUiApplication().invokeLater ( new Runnable()
{
public void run ()
{
UiApplication.getUiApplication().pushScreen(new MyTripScreen());
close();
}
}
);
解决了!还是谢谢你。 当你陷入困境时,如果你能找个人谈谈,这会有很大的帮助 但我仍然不知道这两者之间有什么区别:
protected boolean touchEvent(TouchEvent message)
{
int x = message.getX( 1 );
int y = message.getY( 1 );
boolean isOutOfBounds = false;
if( x < 0 || y < 0 || x > getExtent().width || y > getExtent().height ) {
// Outside the field
// close();//!
// return true;
isOutOfBounds = true;
}
switch( message.getEvent() ) {
case TouchEvent.UNCLICK:
// close in TouchEvent, if out of bounds
if(isOutOfBounds)
{
close();
return true;
}
close();
return true;
}
return super.touchEvent( message );
}