本帖最后由 hoibo 于 2023-11-9 00:50 编辑
if service.isSeekBar(node)
require "import"
import "android.graphics.Rect"
import "android.widget.*"
import "android.view.*"
local t={"0","5","10","15","20","25","30","35","40","45","50","55","60","65","70","75","80","85","90","95","100",}
layout=
{
LinearLayout,orientation=1,layout_width=-1,layout_height=-1,{
EditText,hint="请输入百分比",Gravity="center_horizontal",id="edit",InputType="phone",layout_width=-1,layout_weight=1,},
{Button,text="确定",onClick="zb",layout_width=-1,layout_weight=1,},
{GridView,id="grid",numColumns=4,Gravity="center_horizontal",layout_weight=1,}
}
dlg=LuaDialog(service)
dlg.View=loadlayout(layout)
grid.adapter=SingleLineAdapter(service,String(t))
dlg.show()
grid.onItemClick=function(l,v,p,i)
dlg.dismiss()
local p=Rect()
node.getBoundsInScreen(p)
service.click({{"["..tonumber(p.left)..","..tonumber(p.top+(p.bottom-p.top)/2)..","..tonumber(p.left+(p.right-p.left)/100*v.text)..","..tonumber(p.top+(p.bottom-p.top)/2)..",300]"}})
end
function zb()
local p=Rect()
node.getBoundsInScreen(p)
dlg.dismiss()
service.click({{"["..tonumber(p.left)..","..tonumber(p.top+(p.bottom-p.top)/2)..","..tonumber(p.left+(p.right-p.left)/100*edit.text)..","..tonumber(p.top+(p.bottom-p.top)/2)..",300]"}})
end
else
service.asyncSpeak("当前焦点不是进度滑块")
end
return true |