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空'}} |
UIstr = { style = 'default', width = ({screen.size()})[1], height = ({screen.size()})[2], button = {'取消','确认'}, views = { {type='Label',text='Lable空'}, }}UIstr = { style = 'default', title = 'Func UI例子', width = ({screen.size()})[1], height = h, config = 'test', timeout = 60, button = {'取消','确认'}, views = { {type='Label',text='Lable空'}, {type='Edit',caption='Edit空'}, }}
Lable 元素
| 参数 |
讲解 |
必填 |
类型 |
例 |
| type |
判断控件类型 |
* |
String |
type='Lable' |
| text |
展示内容 |
* |
String |
text='这是个例子' |
| background |
背景色(省略为白色) |
|
Number |
background=0xff0000 |
| color |
字体色(省略为黑色) |
|
Number |
color=0xffffff |
| align |
文字位置(省略为居中) |
|
String |
align='left' |
{type='Label',text='Lable空'},{type='Label',text='Lable左边\n背景红色',background=0xff0000,color=0xffffff,align='left'},{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 |
{type='Edit',caption='Edit空'},{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 |
{type='EditMulti',text='Edit空'},{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 |
{type='ComboBox',item={'ComboBox1','ComboBox2'}},{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 |
{type='RadioGroup',item={'RadioGroup1','RadioGroup2'}},{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 |
{type='CheckBoxGroup',item={'CheckBoxGroup1','CheckBoxGroup2'}},{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 |
{type='Image',src='f.png'}, --文件存放至/User/Media/1ferver/img/{type='Image',src='http://ttaozi.com/tlog/zfb.gif'},{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' |
{type='Iframe',src='http://www.baidu.com'},
例子
local showUI = require("showUI")local w, h = screen.size()local uitable = { style = 'default', title = 'XXTouch UI例子', width = w, height = h, config = 'test', timeout = 60, button = {'取消','确认'}, views = { {type='Label',text='Lable空'}, {type='Edit',caption='Edit空'}, {type='EditMulti',text='Edit空'}, {type='ComboBox',item={'ComboBox1','ComboBox2'}}, {type='RadioGroup',item={'RadioGroup1','RadioGroup2'}}, {type='CheckBoxGroup',item={'CheckBoxGroup1','CheckBoxGroup2'}}, {type='Image',src='f.png'}, {type='Image',src = 'http://ttaozi.com/tlog/zfb.gif'}, {type='Image',src='http://stock.591hx.com/images/hnimg/201405/20/65/14829989175739416965.jpg'}, {type='Iframe',src='http://www.baidu.com'}, }}confirm, selects = showUI(uitable)sys.alert(table.concat({ '点击:' .. ((confirm and uitable.button[2]) or uitable.button[1]), 'Edit:' .. selects[1], 'EditMulti:' .. selects[2], 'ComboBox:' .. uitable.views[4].item[tonumber(selects[3])], 'RadioGroup:' .. uitable.views[5].item[tonumber(selects[4])], 'CheckBoxGroup:' .. (function() local check = {} for l = 1, string.len(selects[5]) do if string.sub(selects[5],l,l) == '1' then table.insert(check,uitable.views[6].item[l]) end end return table.concat(check,',') end)()},'\r\n'))