0

我是 sencha touch 的新手。我为数字键盘编写了代码,但按钮是垂直显示的。我的代码是

Ext.define("exercise.view.Numberplate",{
    extend: "Ext.SegmentedButton",
    requires:['Ext.Button'],
    xtype:'Numberplate',
    allowMultiple: true,
    config: {
        pack:'center',
        centered:true,
        height:30,
        width:100,
        xtype:'button',
        items: [
            {
                xtype:'segmentedbutton',
                allowDepress:true,
                scroll:true,
                //layout:'vbox',
                items:[
                    {
                      text:'1',
                        width:100
                    },
                    {
                        text   : '2',
                        width:100
                    },
                    {
                        text: '3',
                        width:100
                    }
                ]
            },
            {
                xtype:'segmentedbutton',
                //centered:true,
                pack:'center',
                items:[
                    /*  {
                     centered:true,
                     html: [
                     '<br><br><br><br>'
                     ].join("")

                     },*/
                    {
                        text:'4',
                        width:100
                    },
                    {
                        text:'5',
                        width:100
                    },
                    {
                        text:'6',
                        width:100
                    }
                ]
            }
        ]

    },
    constructor: function() {
        this.on({
            scope: this,
            delegate: 'button',

            tap: 'tapHandler'
        });

        this.callParent(arguments);
    },

    tapHandler: function(button) {
        alert(button.getText());
        // this.setHtml("<span class=action>User tapped " + button.getText() + "</span>");
    }
});

我试过了,但我没有得到这个。我认为这很容易,但我不知道该怎么做。谁能帮助我。提前谢谢

4

1 回答 1

0

只需添加layout:vbox到您的配置:

Ext.define("exercise.view.Numberplate",{
extend: "Ext.SegmentedButton",
requires:['Ext.Button'],
xtype:'Numberplate',
allowMultiple: true,
config: {
    layout: 'vbox', // Add right here
    pack:'center',
    centered:true,
    height:30,
    width:100,
    xtype:'button',
    items: [
        {
            xtype:'segmentedbutton',
            allowDepress:true,
            scroll:true,
            //layout:'vbox',
            items:[
                {
                  text:'1',
                    width:100
                },
                {
                    text   : '2',
                    width:100
                },
                {
                    text: '3',
                    width:100
                }
            ]
        },
        {
            xtype:'segmentedbutton',
            //centered:true,
            pack:'center',
            items:[
                /*  {
                 centered:true,
                 html: [
                 '<br><br><br><br>'
                 ].join("")

                 },*/
                {
                    text:'4',
                    width:100
                },
                {
                    text:'5',
                    width:100
                },
                {
                    text:'6',
                    width:100
                }
            ]
        }
    ]

},
constructor: function() {
    this.on({
        scope: this,
        delegate: 'button',

        tap: 'tapHandler'
    });

    this.callParent(arguments);
},

tapHandler: function(button) {
    alert(button.getText());
    // this.setHtml("<span class=action>User tapped " + button.getText() + "</span>");
}
});

希望能帮助到你 :)

于 2013-01-10T06:07:56.223 回答