Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Events GWT-运行时检测不同的屏幕分辨率_Events_Gwt - Fatal编程技术网

Events GWT-运行时检测不同的屏幕分辨率

Events GWT-运行时检测不同的屏幕分辨率,events,gwt,Events,Gwt,我希望我的应用程序在分辨率足够大且处于横向模式时更改UI的不同部分,并在应用程序运行时检测更改(例如,移动设备上的屏幕旋转) 我知道我应该让一个事件监听屏幕分辨率(可以通过javascript获得),但我不知道如何做到这一点。如何在总是刷新的值上挂起事件?您需要窗口。addResizeHandler Window.addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent e

我希望我的应用程序在分辨率足够大且处于横向模式时更改UI的不同部分,并在应用程序运行时检测更改(例如,移动设备上的屏幕旋转)


我知道我应该让一个事件监听屏幕分辨率(可以通过javascript获得),但我不知道如何做到这一点。如何在总是刷新的值上挂起事件?

您需要
窗口。addResizeHandler

Window.addResizeHandler(new ResizeHandler() {

    @Override
    public void onResize(ResizeEvent event) {
        yourCustomLayoutAdjustmentMethod(event.getHeight(), event.getWidth());
    }
});

不需要JavaScript

带有MGWT库():

导入这些类

import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent;
import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent.ORIENTATION;
import com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeHandler;
import com.googlecode.mgwt.ui.client.MGWT;
定义一个方向处理程序

class MyOrientationChangeHandler implements OrientationChangeHandler {
    @Override
    public void onOrientationChanged(OrientationChangeEvent event) {
        switch (event.getOrientation()) {
            case LANDSCAPE:
                // handle landscape orientation
                return;
            case PORTRAIT:
                // handle portrait orientation
                return;

        }
    }
}
添加你的处理程序

MGWT.addOrientationChangeHandler(new MyOrientationChangeHandler ());