A Sencha Touch tab panel example

The following code shows how I created a tab panel in a Sencha Touch application, with a few important parts highlighted:

Ext.define('RadioMobile.view.MainTabPanel', {
    extend: 'Ext.tab.Panel',

    xtype:  'mainTabPanel',
    alias:  'widget.mainTabPanel',

    requires: [
        'RadioMobile.view.TimeControlsPanel',
        'RadioMobile.view.StationsPanel',
        'RadioMobile.view.StreamsPanel',
        'RadioMobile.view.RecordingsPanel',
        'RadioMobile.view.PodcastsPanel'
    ],

    config: {
        fullscreen : true,
        tabBar: {
            docked: 'bottom',
            layout: {
                pack: 'center'
            }
        }
    },

    initialize: function() {
        this.callParent(arguments);
        // the main panels that will show up in the bottom toolbar
        this.add(Ext.create('RadioMobile.view.TimeControlsPanel'));
        this.add(Ext.create('RadioMobile.view.StationsPanel'));
        this.add(Ext.create('RadioMobile.view.StreamsPanel'));
        this.add(Ext.create('RadioMobile.view.RecordingsPanel'));
        this.add(Ext.create('RadioMobile.view.PodcastsPanel'));
        this.setActiveItem(0);
    }

});

This code results in the following mobile UI, in particular the "tabs" shown at the bottom of the image:

Sencha Touch tab panel example

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.