B2B网络软件

标题: 单选控件[uiRadioButton]方法小结 [打印本页]

作者: YYPOST群发软件    时间: 2 小时前
标题: 单选控件[uiRadioButton]方法小结
单选控件[uiRadioButton]方法小结
单选控件[uiRadioButton]方法小结 B2B网络软件

单选控件[uiRadioButton]方法小结 B2B网络软件

单选控件[uiRadioButton]方法小结 B2B网络软件

  1. /**
  2. * uiRadioButton 控件完整示例
  3. * 🍎交流QQ群711841924群一,苹果内测群,528816639
  4. */

  5. // 方法 1: 加载单选控件
  6. // uiRadioButton findViewById(String arg0)
  7. // 功能: 加载单选控件
  8. // 案例: new uiRadioButton().findViewById(控件ID="")
  9. var radioControl = new uiRadioButton().findViewById("myRadioGroup");

  10. // 方法 2: 获取选中项
  11. // String getRadio()
  12. // 功能: 获取选中项
  13. // 案例: new uiRadioButton().getRadio()
  14. var selectedValue = new uiRadioButton().getRadio();

  15. // 方法 3: 设置高度
  16. // void setHeight(int arg0)
  17. // 功能: 设置高度
  18. // 案例: new uiRadioButton().setHeight(0)
  19. new uiRadioButton().setHeight(100);

  20. // 方法 4: 设置选中项
  21. // String setRadio(String arg0)
  22. // 功能: 设置选中项
  23. // 案例: new uiRadioButton().setRadio('')
  24. var result = new uiRadioButton().setRadio("option1");
复制代码
[color=var(--md-box-h3-text-color,var(--md-box-global-text-color))]方法 1:加载单选控件
项目
内容
功能
加载单选控件
方法
uiRadioButton findViewById(String arg0)
返回值
uiRadioButton
参数
String arg0: 控件 id
案例
new uiRadioButton ().findViewById (控件 ID="")
[color=var(--md-box-h3-text-color,var(--md-box-global-text-color))]方法 2:获取选中项
项目
内容
功能
获取选中项
方法
String getRadio()
返回值
String
参数
-
案例
new uiRadioButton().getRadio()
[color=var(--md-box-h3-text-color,var(--md-box-global-text-color))]方法 3:设置高度
项目
内容
功能
设置高度
方法
void setHeight(int arg0)
返回值
void
参数
int arg0: 高度
案例
new uiRadioButton().setHeight(0)
[color=var(--md-box-h3-text-color,var(--md-box-global-text-color))]方法 4:设置选中项
项目
内容
功能
设置选中项
方法
String setRadio(String arg0)
返回值
String
参数
String arg0: 选中项标识
案例
new uiRadioButton().setRadio('')



  1. /**
  2. * 🍎交流QQ群711841924群一,苹果内测群,528816639
  3. * 演示如何使用 uiRadioButton 控件的相关方法
  4. */

  5. // 日志窗口初始化和最大化
  6. function initLogWindow() {
  7.     try {
  8.         // 创建logWindow实例
  9.         var logWin = new logWindow();
  10.         
  11.         // 清空历史日志
  12.         logWin.clear();
  13.         
  14.         // 设置窗口属性
  15.         logWin.setWidth(800);
  16.         logWin.setHeight(600);
  17.         
  18.         // 设置透明度
  19.         logWin.setAlpha(0.8);
  20.         
  21.         // 设置字体样式
  22.         logWin.setColor("#00FF00"); // 绿色
  23.         logWin.setSize(14);
  24.         
  25.         // 设置显示模式
  26.         logWin.showModel(0); // 全量显示
  27.         
  28.         // 设置交互模式
  29.         logWin.setClickModel(); // 启用点击
  30.         
  31.         // 最大化显示
  32.         logWin.showMax(); // 最大化显示
  33.         
  34.         printl("日志窗口初始化完成");
  35.         print.log("日志窗口初始化完成");
  36.     } catch (error) {
  37.         printl("日志窗口初始化出错: " + String(error));
  38.         print.log("日志窗口初始化出错: " + String(error));
  39.     }
  40. }

  41. // 创建一个示例函数来演示用法
  42. function uiRadioButtonTianTianExample() {
  43.     try {
  44.         // 推荐方式:直接链式调用获取选中项
  45.         var selectedValue = uiRadioButton.findByID("天天").getRadio();
  46.         printl("当前选中项: " + selectedValue);
  47.         print.log("当前选中项: " + selectedValue);
  48.         
  49.         // 也可以明确分步完成
  50.         var radioControl = uiRadioButton.findByID("天天");
  51.         var selectedValue2 = radioControl.getRadio();
  52.         printl("分步获取选中项: " + selectedValue2);
  53.         print.log("分步获取选中项: " + selectedValue2);
  54.         
  55.         return selectedValue;
  56.     } catch (error) {
  57.         printl("获取选中项时出错: " + String(error));
  58.         print.log("获取选中项时出错: " + String(error));
  59.         return null;
  60.     }
  61. }

  62. // 扩展示例:设置选中项并获取
  63. function setAndGetRadioExample() {
  64.     try {
  65.         // 直接链式调用设置选中项
  66.         var setResult = uiRadioButton.findByID("天天").setRadio("选项1");
  67.         printl("设置选中项结果: " + setResult);
  68.         print.log("设置选中项结果: " + setResult);
  69.         
  70.         // 直接链式调用获取当前选中项
  71.         var selectedValue = uiRadioButton.findByID("天天").getRadio();
  72.         printl("设置后的选中项: " + selectedValue);
  73.         print.log("设置后的选中项: " + selectedValue);
  74.         
  75.         return selectedValue;
  76.     } catch (error) {
  77.         printl("设置或获取选中项时出错: " + String(error));
  78.         print.log("设置或获取选中项时出错: " + String(error));
  79.         return null;
  80.     }
  81. }

  82. // 实际使用场景示例
  83. function practicalUsageExample() {
  84.     printl("=== uiRadioButton 天天控件使用示例 ===");
  85.     print.log("=== uiRadioButton 天天控件使用示例 ===");
  86.    
  87.     // 获取当前选中项
  88.     var currentSelection = uiRadioButtonTianTianExample();
  89.    
  90.     // 根据选中项执行不同操作
  91.     if (currentSelection) {
  92.         switch(currentSelection) {
  93.             case "选项1":
  94.                 printl("执行选项1相关操作");
  95.                 print.log("执行选项1相关操作");
  96.                 // 在这里添加选项1的处理逻辑
  97.                 break;
  98.             case "选项2":
  99.                 printl("执行选项2相关操作");
  100.                 print.log("执行选项2相关操作");
  101.                 // 在这里添加选项2的处理逻辑
  102.                 break;
  103.             case "选项3":
  104.                 printl("执行选项3相关操作");
  105.                 print.log("执行选项3相关操作");
  106.                 // 在这里添加选项3的处理逻辑
  107.                 break;
  108.             default:
  109.                 printl("处理选项: " + currentSelection);
  110.                 print.log("处理选项: " + currentSelection);
  111.                 // 对于其他选项的通用处理
  112.         }
  113.     } else {
  114.         printl("未能获取到选中项");
  115.         print.log("未能获取到选中项");
  116.     }
  117. }

  118. // 主函数:先初始化日志窗口,再运行示例
  119. function main() {
  120.     // 初始化并最大化日志窗口
  121.     initLogWindow();
  122.    
  123.     // 等待日志窗口初始化完成
  124.     sleep.millisecond(500);
  125.    
  126.     // 运行示例
  127.     practicalUsageExample();
  128.    
  129.     // 单独运行设置和获取示例
  130.     setAndGetRadioExample();
  131. }

  132. // 运行主函数
  133. main();
复制代码








欢迎光临 B2B网络软件 (http://bbs.niubt.cn/) Powered by Discuz! X3.2