Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
Google app engine mgwt中未触发Tap事件_Google App Engine_Gwt_Mgwt - Fatal编程技术网

Google app engine mgwt中未触发Tap事件

Google app engine mgwt中未触发Tap事件,google-app-engine,gwt,mgwt,Google App Engine,Gwt,Mgwt,我刚刚开始学习。创建按钮并添加点击处理程序后,不会触发点击事件。我不知道代码中有什么错误。我已经在GAE上部署了它,并在Android设备上访问了该站点。下面是onModuleLoad()的代码 有人能帮我解决这个问题吗?谢谢 您正在向一个区域添加多个AnimatableDisplays。这些将重叠 我想您只是在mgwt showcase中添加了一些代码行,而没有删除showcase代码。要解决此问题,可以从计时器中删除对start()的调用。什么类型的布局以及为什么要将其添加到根面板,而不仅仅

我刚刚开始学习。创建
按钮
并添加
点击处理程序
后,不会触发点击事件。我不知道代码中有什么错误。我已经在GAE上部署了它,并在Android设备上访问了该站点。下面是onModuleLoad()的代码


有人能帮我解决这个问题吗?谢谢

您正在向一个区域添加多个AnimatableDisplays。这些将重叠


我想您只是在mgwt showcase中添加了一些代码行,而没有删除showcase代码。要解决此问题,可以从计时器中删除对start()的调用。

什么类型的布局以及为什么要将其添加到根面板,而不仅仅是使用AnimationHelper?布局是
com.googlecode.mgwt.ui.client.widget.LayoutPanel
。我没有将它添加到
根面板
,但是没有成功。您可以更新您的代码示例以显示完整的代码,以便我们能够找出代码的错误吗?我已经更新了代码,这是该类的完整代码。
import com.citrix.demo.client.css.AppBundle;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
import com.google.gwt.dom.client.StyleInjector;
import com.google.gwt.place.shared.PlaceHistoryHandler;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.googlecode.mgwt.dom.client.event.tap.TapEvent;
import com.googlecode.mgwt.dom.client.event.tap.TapHandler;
import com.googlecode.mgwt.mvp.client.AnimatableDisplay;
import com.googlecode.mgwt.mvp.client.AnimatingActivityManager;
import com.googlecode.mgwt.mvp.client.Animation;
import com.googlecode.mgwt.mvp.client.AnimationMapper;
import com.googlecode.mgwt.ui.client.MGWT;
import com.googlecode.mgwt.ui.client.MGWTSettings;
import com.googlecode.mgwt.ui.client.MGWTStyle;
import com.googlecode.mgwt.ui.client.animation.AnimationHelper;
import com.googlecode.mgwt.ui.client.dialog.TabletPortraitOverlay;
import com.googlecode.mgwt.ui.client.layout.MasterRegionHandler;
import com.googlecode.mgwt.ui.client.layout.OrientationRegionHandler;
import com.googlecode.mgwt.ui.client.widget.Button;
import com.googlecode.mgwt.ui.client.widget.LayoutPanel;

/**
 * @author Daniel Kurka
 * 
 */
public class MgwtAppEntryPoint implements EntryPoint {
    private static LayoutPanel layout = new LayoutPanel();

    private void start() {

        //set viewport and other settings for mobile
        MGWT.applySettings(MGWTSettings.getAppSetting());
        final ClientFactory clientFactory = new ClientFactoryImpl();

        // Start PlaceHistoryHandler with our PlaceHistoryMapper
        AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class);
        final PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);

        historyHandler.register(clientFactory.getPlaceController(), clientFactory.getEventBus(), new com.citrix.demo.client.activities.HomePlace());

        if ((MGWT.getOsDetection().isTablet())) {
            // very nasty workaround because GWT does not correctly support
            // @media
            StyleInjector.inject(AppBundle.INSTANCE.css().getText());

            createTabletDisplay(clientFactory);
        } else {
            createPhoneDisplay(clientFactory);

        }
        historyHandler.handleCurrentHistory();

    }

    private void createPhoneDisplay(ClientFactory clientFactory) {

        AnimatableDisplay display = GWT.create(AnimatableDisplay.class);
        PhoneActivityMapper appActivityMapper = new PhoneActivityMapper(clientFactory);
        PhoneAnimationMapper appAnimationMapper = new PhoneAnimationMapper();
        AnimatingActivityManager activityManager = new AnimatingActivityManager(appActivityMapper, appAnimationMapper, clientFactory.getEventBus());
        activityManager.setDisplay(display);
        RootPanel.get().add(display);
    }

    private void createTabletDisplay(ClientFactory clientFactory) {

        SimplePanel navContainer = new SimplePanel();
        navContainer.getElement().setId("nav");
        navContainer.getElement().addClassName("landscapeonly");
        AnimatableDisplay navDisplay = GWT.create(AnimatableDisplay.class);
        final TabletPortraitOverlay tabletPortraitOverlay = new TabletPortraitOverlay();
        new OrientationRegionHandler(navContainer, tabletPortraitOverlay, navDisplay);
        new MasterRegionHandler(clientFactory.getEventBus(), "nav", tabletPortraitOverlay);
        ActivityMapper navActivityMapper = new TabletNavActivityMapper(clientFactory);
        AnimationMapper navAnimationMapper = new TabletNavAnimationMapper();
        AnimatingActivityManager navActivityManager = new AnimatingActivityManager(navActivityMapper, navAnimationMapper, clientFactory.getEventBus());
        navActivityManager.setDisplay(navDisplay);
        RootPanel.get().add(navContainer);

        SimplePanel mainContainer = new SimplePanel();
        mainContainer.getElement().setId("main");
        AnimatableDisplay mainDisplay = GWT.create(AnimatableDisplay.class);
        TabletMainActivityMapper tabletMainActivityMapper = new TabletMainActivityMapper(clientFactory);
        AnimationMapper tabletMainAnimationMapper = new TabletMainAnimationMapper();
        AnimatingActivityManager mainActivityManager = new AnimatingActivityManager(tabletMainActivityMapper, tabletMainAnimationMapper, clientFactory.getEventBus());
        mainActivityManager.setDisplay(mainDisplay);
        mainContainer.setWidget(mainDisplay);
        RootPanel.get().add(mainContainer);

    }

    @Override
    public void onModuleLoad() {

        GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
            @Override
            public void onUncaughtException(Throwable e) {
                Window.alert("uncaught: " + e.getMessage());
                e.printStackTrace();
            }
        });

        new Timer() {
            @Override
            public void run() {
                start();
            }
        }.schedule(1);

        //set viewport and other settings for mobile
        MGWT.applySettings(MGWTSettings.getAppSetting());
        MGWTStyle.getTheme().getMGWTClientBundle().getMainCss().ensureInjected();
        Label label = new Label("Welcome");
        label.setAutoHorizontalAlignment(Label.ALIGN_CENTER);
        Button button = new Button();
        button.setRound(true);
        button.setText("Click");
        button.addTapHandler(new TapHandler() {
            @Override
            public void onTap(TapEvent event) {
                Window.alert("Hola !");             
            }
        });

        layout.add(label);
        layout.add(button);
        //build animation helper and attach it
        AnimationHelper animationHelper = new AnimationHelper();
//      RootPanel.get().add(layout);
        RootPanel.get().add(animationHelper);
        animationHelper.goTo(layout, Animation.POP);
    }
}