-- 设置为竖屏模式
activity.setRequestedOrientation(1)

function hexToColor(hex)
 -- 去掉 # 前缀
 hex = hex:gsub("#", "")
 -- 将十六进制转换为数字
 local color = tonumber(hex, 16)
 return color
end

local hexColor = "#ff009688"
local MyColor = hexToColor(hexColor)
写入文件(随机色,MyColor)
读取颜色(随机色,随机色)

layout = {
 LinearLayout,
 orientation ='vertical',
 layout_width = 'fill',
 layout_height = 'fill',
 background = '#ffffff',
 {
 TextView,
 text = '更多应用',
 textSize = '20sp',
 textColor = '#333333',
 layout_gravity = "center|bottom",
 layout_marginTop = '35px',
 },
 {
 TextView,
 layout_width = '97.4%w',
 layout_height = '5px',
 layout_marginTop = '10dp',
 layout_marginBottom = '10dp',
 layout_gravity = 'center',
 backgroundColor = MyColor
 },
 {
 GridView,
 id = "list",
 numColumns = 3,
 layout_width = 'fill',
 layout_height = 'fill',
 horizontalSpacing = "3dp",
 verticalSpacing = "0dp",
 layout_gravity = "center",
 OverScrollMode = 2
 }
}

webView.addView(loadlayout(layout))

function 布局边框(边框粗细, 边框颜色, 背景颜色, 圆角大小)
 import "android.graphics.drawable.GradientDrawable"
 drawable = GradientDrawable()
 drawable.setShape(GradientDrawable.RECTANGLE)
 drawable.setStroke(边框粗细, tonumber(边框颜色))
 drawable.setColor(tonumber(背景颜色))
 drawable.setCornerRadius(圆角大小)
 return drawable
end

item = {
 LinearLayout,
 layout_height = "48dp",
 layout_width = "fill",
 {
 LinearLayout,
 layout_height = "fill",
 layout_width = "fill",
 layout_margin = "5dp",
 BackgroundDrawable = 布局边框(4,MyColor, 0x00000000, 15),
 {
 TextView,
 id = "name",
 layout_height = "fill",
 layout_width = "fill",
 gravity = "center",
 textColor = "#FF000000"
 },
 {
 TextView,
 id = "tools",
 layout_width = "0dp",
 layout_height = "0dp"
 }
 }
}

adapter = LuaAdapter(activity, item)

function getToolsText(v)
 return v.Tag.tools and v.Tag.tools.text or ""
end

list.onItemClick = function(l, v, p, i)
 local toolsText = getToolsText(v)
 if toolsText:find '://' then
 --print("正在加载\n".. v.Tag.name.text)
 子页面('安卓',toolsText)
 elseif toolsText:find '文字翻转' then
 文字翻转()
 elseif toolsText:find 'QQ聊天' then
 ------- 
 zdy_layout={
 LinearLayout;
 orientation="vertical";--重力属性
 id="zdy_father_layout",
 {
 EditText;--编辑框控件
 id="pathedit",
 layout_marginTop='15dp';--布局顶距
 layout_width="80%w";--编辑框宽度
 layout_gravity="center";--重力属性
 Hint="请输入QQ号";--设置编辑框为空时的提示文字
 };
 };
 AlertDialog.Builder(this)
 .setTitle("QQ聊天")--设置标题
 .setCancelable(false)--点击外围可取消
 .setView(loadlayout(zdy_layout))--设置布局
 .setPositiveButton("聊一聊",function(v)--设置积极按钮
 联系QQ(pathedit.text)
 end)
 .setNegativeButton("取消",function(v)--设置消极按钮
 end)
 .show()
 ------- 
 elseif toolsText:find '关于我们' then
 关于()
 elseif toolsText:find 'jm' then
 解密云程序(toolsText)
 elseif toolsText:find '微信扫一扫' then
 微信扫一扫()
 elseif toolsText:find '网页计算器' then
 子页面("安卓","file:///android_asset/htm/jisuanqi/index.html")
 elseif toolsText:find '万年历' then
子页面("安卓","file:///android_asset/htm/wnl/sxwnl/source/indexmp.htm")
 elseif toolsText:find '二维码' then
 子页面("安卓","file:///android_asset/htm/ewm/index.html") 
 elseif toolsText:find '支付宝扫一扫' then
 支付宝扫一扫()
 elseif toolsText:find 'diantong' then
 print ('预防误碰，请长按！')
 else
 -------------------
 WEB小程序(toolsText)
 -------------------
 end
end

list.onItemLongClick = function(l, v, p, i)
 local toolsText = getToolsText(v)
 if toolsText:find '://' then
 print("使用系统默认浏览器打开\n".. toolsText)
 调用浏览器(toolsText)
 return true
 elseif toolsText:find 'diantong' then
 手电筒()
 return true
 else
 print ('暂时没有添加长按功能噢😃！')
 return true
 end
end

list.Adapter = adapter

local dataList = {
 {name = "编辑器", tools = "bianjiqi1"},
 {name = "全网搜索", tools = "sousuo"},
 {name = "老版应用", tools = "yingyong"},
 {name = "特殊字符", tools = "zifu"},
 {name = "指南针", tools = "zhinanzhen"},
 {name = "幸运数字", tools = "suiji"},
 {name = "QQ聊天", tools = "QQ聊天"},
 {name = "微信扫一扫", tools = "微信扫一扫"},
 {name = "支付宝扫一扫", tools = "支付宝扫一扫"},
 {name = "计算器小程序", tools = "jisuanqi"},
 {name = "网页计算器", tools = "网页计算器"},
 {name = "小时钟", tools = "clock"},
 {name = "文字图标", tools = "wztb"},
 {name = "一把尺子", tools = "rule"},
 {name = "蹦蹦跳跳", tools = "tiao"},
 {name = "文字翻转", tools = "文字翻转"},
 {name = "微信零钱", tools = "0qian"},
 {name = "微信零钱通", tools = "0qiantong"},
 {name = "井字棋", tools = "jing"},
 {name = "万年历", tools = "万年历"},
 {name = "手电筒(长按)", tools = "diantong"},
 {name = "二维码", tools = "二维码"},
 {name = "加密文档", tools = "wendang"},
 {name = "关于我们", tools = "关于我们"},
}

for _, data in ipairs(dataList) do
 adapter.add(data)
end