如果触摸事件发生在对话框字段的旁边,我可以在对话框中关闭自己吗?我可以在相反的情况下很好地关闭它,如下面的代码所示:
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 );
}
答案 0 :(得分:0)
试试这个。 而不是写近距离写这个。希望它能奏效。
UiApplication.getUiApplication().invokeLater ( new Runnable()
{
public void run ()
{
UiApplication.getUiApplication().pushScreen(new MyTripScreen());
close();
}
}
);
答案 1 :(得分:0)
解决!谢谢你们。 如果你在遇到困难时能与某人谈话,那将是很有帮助的。
但我仍然不知道这两者之间的区别是什么:
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 );
}