touch4j 4.0 google map UIbinder change view

To change view:

add an abstract class for content:

public abstract class Content extends Composite

Inside the  TouchEntryPoint:

private static final HelloTouch INSTANCE = new HelloTouch();
    private Content content;

    public static HelloTouch getInstance(){
        return INSTANCE;

    public void onLoad()
        HelloTouch.getInstance().setContent(new MyGoogleMap());

    public void setContent(Content content){
        this.content = content;

For UI binder, same way as we use in GWT.

Just add the touch4j namespace:

<ui:UiBinder xmlns:ui=''
   <touch:Panel ui:field="container"  >
      <touch:ToolBar docked="top" title="My ToolBar">
         <touch:Button text="Back"  ui="back" ui:field="backButton"  />
         <touch:Spacer />
         <touch:Button  ui="plain" iconMask="true" iconCls="info"  ui:field="infoButton" />
      <touch:GoogleMap useCurrentLocation="true" />

The corresponding class could be:

interface xxx extends UiBinder<Panel, MyGoogleMap>

    private static xxxUiBinder ourUiBinder = GWT.create(xxxUiBinder.class);

    Button infoButton;
    Button backButton;

    public MyGoogleMap()
        Panel rootElement = ourUiBinder.createAndBindUi(this);

        infoButton.addTapHandler(new TapHandler()
            public void onTap(Button button, EventObject event)
                MessageBox.alert("Welcome Here");

        backButton.addTapHandler(new TapHandler()
            public void onTap(Button button, EventObject eventObject)
                 HelloTouch.getInstance().setContent(new SecondView());



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s