Buttons in a same row

蓝咒 提交于 2019-12-12 04:47:53

问题


Here my code in sencha touch, i tried to add 2 button horizontaly, Means one to other.No,luck its keep on coming one in upper side and the other one lower.

 var profilese = {
            standardSubmit : false,
            items: [tab,{
                    xtype:  'button',
                    text:   'ADD',
                    ui: 'confirm',
                    handler: function() {
                    view.setActiveItem(2, {type:'fade', direction:'right'});
                    }
                    },{
                    xtype:  'DELETE',
                    text:   'Search Friends',
                    ui: 'Search',
                    handler: function() {
                    view.setActiveItem(3, {type:'fade', direction:'right'});
                    }
                    }]
                };

How to set button in a same row.Please help me to sort it out.


回答1:


I'm not sure what tab is in your code, but what you need to get the buttons aligned horizontally is an hbox layout:

layout: 'hbox',
items: [
    {
        xtype:  'button',
        text:   'ADD',
        ui: 'confirm',
        handler: function() {
            view.setActiveItem(2, {type:'fade', direction:'right'});
        }
    },{
        xtype:  'button',
        text:   'Search Friends',
        ui: 'Search',
        handler: function() {
            view.setActiveItem(3, {type:'fade', direction:'right'});
        }
    }
]

http://docs.sencha.com/touch/2.2.1/#!/api/Ext.layout.HBox




回答2:


In ExtJS point, there must be a container as parent to hold the children(Buttons). And the set the layout config as "hbox".

The code must look like,

  items:[
  tab,
  {
   xtype:'container',
   layout:'hbox',
   items:[
    {
      xtype:'button1'
    },
    { 
      xtype:'button2'
    }
   ]
  }
  ]



回答3:


layout: {
    type: 'column'
  },
items: [
    {
        xtype:  'button',
        columnWidth: 0.5,
        text:   'ADD',
        ui: 'confirm',
        handler: function() {
            view.setActiveItem(2, {type:'fade', direction:'right'});
        }
    },{
        xtype:  'button',
        columnWidth: 0.5,
        text:   'Search Friends',
        ui: 'Search',
        handler: function() {
            view.setActiveItem(3, {type:'fade', direction:'right'});
        }
    }
]


来源:https://stackoverflow.com/questions/18401887/buttons-in-a-same-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!