[关闭]
@chendbdb 2017-03-03T21:29:05.000000Z 字数 4692 阅读 2889

showUI

showUI XXTouch


showUI

参数 讲解 必填 类型
style 样式选项(目前仅此一项) * String style = 'default',
title 展示内容(省略为空) String 'Func UI例子'
width 窗体宽度 * Number width = ({screen.size()})[1]
height 窗体高度 * Number height = ({screen.size()})[2]
config 配置文件(留空则不储存) String config = 'test'
timeout 超时处理 Number timeout = 60
button 按钮标题 * Table{String} button = {'取消','确认'}
views 窗体子元素 * Table{element} views = {{type='Label',text='Lable空'}}
  1. UIstr = {
  2. style = 'default',
  3. width = ({screen.size()})[1],
  4. height = ({screen.size()})[2],
  5. button = {'取消','确认'},
  6. views = {
  7. {type='Label',text='Lable空'},
  8. }
  9. }
  10. UIstr = {
  11. style = 'default',
  12. title = 'Func UI例子',
  13. width = ({screen.size()})[1],
  14. height = h,
  15. config = 'test',
  16. timeout = 60,
  17. button = {'取消','确认'},
  18. views = {
  19. {type='Label',text='Lable空'},
  20. {type='Edit',caption='Edit空'},
  21. }
  22. }

Lable 元素

参数 讲解 必填 类型
type 判断控件类型 * String type='Lable'
text 展示内容 * String text='这是个例子'
background 背景色(省略为白色) Number background=0xff0000
color 字体色(省略为黑色) Number color=0xffffff
align 文字位置(省略为居中) String align='left'
  1. {type='Label',text='Lable空'},
  2. {type='Label',text='Lable左边\n背景红色',background=0xff0000,color=0xffffff,align='left'},
  3. {type='Label',text='Lable右边\n背景蓝色',background=0x0000ff,color=0xffffff,align='right'},

Edit 元素

参数 讲解 必填 类型
type 判断控件类型 * String type='Edit'
caption 前端展示内容 * String caption='Edit'
text 默内容(有配置文件则被替换) String text='这是个例子'
prompt 背景文字(省略不显示) String prompt='输入数字'
background 背景色(省略为白色) Number background=0xff0000
color 字体色(省略为黑色) Number color=0xffffff
  1. {type='Edit',caption='Edit空'},
  2. {type='Edit',caption='Edit',text='默认内容',prompt='背景红 字蓝',background=0xff0000,color=0x0000ff},

EditMulti 元素

参数 讲解 必填 类型
type 判断控件类型 * String type='EditMulti'
rows 显示的行高(省略则为1) String rows='5'
text 默内容(有配置文件则被替换) String text='这是个例子'
prompt 背景文字(省略不显示) String prompt='输入数字'
background 背景色(省略为白色) Number background=0xff0000
color 字体色(省略为黑色) Number color=0xffffff
  1. {type='EditMulti',text='Edit空'},
  2. {type='EditMulti',rows='5',text='换行\n内容',prompt='背景蓝 字红',background=0x0000ff,color=0xff0000},

ComboBox 元素

参数 讲解 必填 类型
type 判断控件类型 * String type='ComboBox'
item 子元素 * table{String} item={'ComboBox1','ComboBox2'}
select 已选择项(有配置文件则被替换) String select = 'ComboBox1'
background 背景色(省略为白色) Number background=0xff0000
color 字体色(省略为黑色) Number color=0xffffff
  1. {type='ComboBox',item={'ComboBox1','ComboBox2'}},
  2. {type='ComboBox',select = 'aaa', item = {'aaa','bbb','ccc','ddd','eee','fff','ggg','hhh','iii','jjj'},background=0xff0000,color=0xffffff},

RadioGroup 元素

参数 讲解 必填 类型
type 判断控件类型 * String type='RadioGroup'
item 子元素 * table{String} item={'RadioGroup1','RadioGroup2'}
select 已选择项(有配置文件则被替换) String select = 'RadioGroup1'
background 背景色(省略为白色) Number background=0xff0000
color 字体色(省略为黑色) Number color=0xffffff
  1. {type='RadioGroup',item={'RadioGroup1','RadioGroup2'}},
  2. {type='RadioGroup',select = 'aaa', item = {'aaa','bbb','ccc','ddd','eee','fff','ggg','hhh','iii','jjj'},background=0xff0000,color=0xffffff},

CheckBoxGroup 元素

参数 讲解 必填 类型
type 判断控件类型 * String type='CheckBoxGroup'
item 子元素 * table{String} item={'CheckBoxGroup1','CheckBoxGroup2'}
select 已选择项(有配置文件则被替换) table{String} select={'aaa','bbb'}
background 背景色(省略为白色) Number background=0xff0000
color 字体色(省略为黑色) Number color=0xffffff
  1. {type='CheckBoxGroup',item={'CheckBoxGroup1','CheckBoxGroup2'}},
  2. {type='CheckBoxGroup',select = {'aaa','bbb'}, item = {'aaa','bbb','ccc','ddd','eee','fff','ggg','hhh','iii','jjj'},background=0xff0000,color=0xffffff},

Image 元素

参数 讲解 必填 类型
type 判断控件类型 * String type='Image'
src 显示的图片(支持加载本地图片) * String src='http://ttaozi.com/tlog/zfb.gif'
background 背景色(省略为白色) Number background=0xff0000
  1. {type='Image',src='f.png'}, --文件存放至/User/Media/1ferver/img/
  2. {type='Image',src='http://ttaozi.com/tlog/zfb.gif'},
  3. {type='Image',src='http://stock.591hx.com/images/hnimg/201405/20/65/14829989175739416965.jpg'},

Iframe 元素

参数 讲解 必填 类型
type 判断控件类型 * String type='Iframe'
src 加载网络页面 * String src='http://www.baidu.com'
  1. {type='Iframe',src='http://www.baidu.com'},

例子

  1. local showUI = require("showUI")
  2. local w, h = screen.size()
  3. local uitable = {
  4. style = 'default',
  5. title = 'XXTouch UI例子',
  6. width = w,
  7. height = h,
  8. config = 'test',
  9. timeout = 60,
  10. button = {'取消','确认'},
  11. views = {
  12. {type='Label',text='Lable空'},
  13. {type='Edit',caption='Edit空'},
  14. {type='EditMulti',text='Edit空'},
  15. {type='ComboBox',item={'ComboBox1','ComboBox2'}},
  16. {type='RadioGroup',item={'RadioGroup1','RadioGroup2'}},
  17. {type='CheckBoxGroup',item={'CheckBoxGroup1','CheckBoxGroup2'}},
  18. {type='Image',src='f.png'},
  19. {type='Image',src = 'http://ttaozi.com/tlog/zfb.gif'},
  20. {type='Image',src='http://stock.591hx.com/images/hnimg/201405/20/65/14829989175739416965.jpg'},
  21. {type='Iframe',src='http://www.baidu.com'},
  22. }
  23. }
  24. confirm, selects = showUI(uitable)
  25. sys.alert(table.concat({
  26. '点击:' .. ((confirm and uitable.button[2]) or uitable.button[1]),
  27. 'Edit:' .. selects[1],
  28. 'EditMulti:' .. selects[2],
  29. 'ComboBox:' .. uitable.views[4].item[tonumber(selects[3])],
  30. 'RadioGroup:' .. uitable.views[5].item[tonumber(selects[4])],
  31. 'CheckBoxGroup:' .. (function()
  32. local check = {}
  33. for l = 1, string.len(selects[5]) do
  34. if string.sub(selects[5],l,l) == '1' then
  35. table.insert(check,uitable.views[6].item[l])
  36. end
  37. end
  38. return table.concat(check,',')
  39. end)()
  40. },'\r\n'))
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注