2013-01-10 62 views
0

我是新來煎茶touch.I的數字鍵盤寫代碼,但按鈕顯示vertically.my代碼是aligment鍵盤按鈕(數字)

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>"); 
    } 
}); 

我試過,但我沒有得到這。我覺得這很容易,但我不知道該怎麼辦this.can任何人幫助me.thanks提前

回答

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>"); 
} 
}); 

希望它能幫助:)

+0

user1479606,由於其working.In這個程序,我創建了一個名爲作爲field.js,其中包含4個文本fields.in上面的代碼我寫的代碼,當我們按下數字鍵,另一種觀點認爲,警報這裏什麼coming.but我想要的是,當我按下按鈕1,按鈕2或按鈕3時,我想要'1','2'或'3'分別顯示在textfield1中。你可以幫我做到這一點... – lucky

+0

我需要在這個時候去上學但你可以看看這個[廚房水槽演示](http://dev.sencha.com/deploy/touch/examples/production/kitchensink/#demo/toolbars)你可以查看這個應用右上角的源代碼。 – Eli

+0

我檢查那個例子,但我沒有得到它。我會檢查一次again.thanks爲rply – lucky