控件:RadioGroup 单选组合

一共有 9 种属性:控件类型 type、控件 ID id、可选项标题 list、默认选中项编号 select、在可选项上显示图片 images、选项图片缩放 scale、单行控件显示数量 countperline、控件宽度 width、控件是否换行 nowrap

参数 类型 必填 说明 默认值
type string 控件类型:RadioGroup -
id string 为控件指定 ID,可以理解为控件的名称,
在返回类型为 table 时将作为返回 table 中的 key,
控件ID 以 table 格式返回返回值时必填,否则无法获取返回值
-
list string 文字选项,多个可选项之间用英文半角逗号分割 -
select string 默认选项编号,只允许填写一个,序号从 0 开始,
与可选项标题中的顺序保持一致
"0"
images string 图片选项,此属性可单独使用也可以和 list 属性同时使用,
多个图片资源用英文半角逗号分割
-
scale number 选项图片缩放,当 images 属性有效时可用此属性设置
图片资源缩放比例,范围 0 - 1
1
countperline number 单行控件显示数量,
引擎版本支持 iOS v3.00-157,Android v2.3.6 及其以上版本
Android 默认 1 行显示 1 个,
iOS 控件总宽度超过屏幕宽度则堆积在一起
width number 控件宽度,当 showUI 全局属性 style 为 default 时,
如需将多个控件放入同一行显示,可用此属性调整控件宽度。
仅支持引擎版本 iOS v2.2.6, Android v1.2.4 及其以上版本
-1
nowrap number 控件是否换行,当此属性为 1 时,
将指定下一个控件不换行,用于将多个控件放入一行显示。
仅支持引擎版本 iOS v2.2.6, Android v1.2.5 及其以上版本
0
返回值 类型 说明
id 字符串 根据控件 ID 返回选择选项的内容,"0" 表示第一个选择了第一个选项,"1" 表示第一个选择了第二个选项,以此类推

函数用例

snapshot("test1.png", 0, 0, 100, 100)
local ts = require("ts")
local cjson = ts.json
w,h = getScreenSize();
MyTable = {
    ["style"]  = "default",    
    ["width"] = w,          
    ["height"] = h,            
    ["cancelname"] = "取消",  
    ["okname"] = "开始", 
    ["title"] = "居中自定义字号",
    ["titlealign"] = "center",
    ["align"] = "center",
    ["titlesize"] = 12,  
    ["titles"] = "单选组合,第二页", 
    ["pagetype"]= "multi",  
    ["selpage"] = 1,   
    ["orient"] = 0, 
    ["btnbkcolor"] = "255,255,255",         
    ["bgcolor"] = "255,255,255",
    ["pagenumtype"] = "tab", 
    ["config"] = "showuiTest1.txt",  
    ["timer"] = 99,  
    ["rettype"] = "table",   
    pages            =
    {
        {
            {
                ["type"] = "Label",
                ["align"] = "center",
                ["text"] = "单选组合-RadioGroup",
                ["size"] = 20,
            },
            {
                ["type"] = "RadioGroup",            
                -- 必填,控件类型,单选组合
                ["id"] = "rg",                      
                -- 选填,无,控件 ID,以 table 格式返回返回值时必填,否则无法获取返回值
                ["list"] = "小学,初中,高中,大学",      -- 必填,无,多选组合内容
                ["select"] = "1",                   -- 选填,0,默认选中项 id
                ["images"] = "test1.png,test1.png,test1.png,test1.png", 
                -- 选填,无, 单选组合选项显示图片
                ["scale"] = 0.4,                    -- 选填,1,图片缩放比例
                ["countperline"] = 1,
            },
        }
    }
}
local MyJsonString = cjson.encode(MyTable);
UIret,values = showUI(MyJsonString)
if UIret == 1 then
    local rg = values.rg
    toast("开始运行脚本")
    if  rg == "0" then
        dialog("小学")
    elseif rg == "1" then
        dialog("初中")
    elseif  rg == "2" then
        dialog("高中")
    elseif rg == "3" then 
        dialog("大学")
    end
else
    toast("取消运行")
end
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""