子控件数量 (Selector.child_count)
Selector.child_count
声明
node.selector():child_count(val)
node.selector():child_count(val1, val2, ...)
参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| val | number | 是 | 子控件数量。可使用小数表示范围,如 6.7 表示 6-7 之间 |
返回值
| 类型 | 说明 |
|---|---|
| Selector | 返回控件查找器,用于链式编程 |
说明
通过子控件数量约束。
待实现
该接口正在开发中。
示例
local node = require("node")
-- 查找子控件个数为 13 的控件
local n = node.selector():child_count(13):find()
-- 查找子控件个数为 6-7 之间或 9-13 之间的所有控件
local nodes = node.selector():child_count(6.7, 9.13):find_all()
if nodes then
for _, n in ipairs(nodes) do
print(n)
end
end
AScript 对应
# AScript (Python)
from ascript.android.node import Selector
node = Selector().childCount(13).find()
nodes = Selector().childCount(6.7, 9.13).find_all()