gitlink.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. -- 设置为竖屏模式
  2. activity.setRequestedOrientation(1)
  3. 读取颜色(随机色,随机色)
  4. layout = {
  5. LinearLayout,
  6. orientation ='vertical',
  7. layout_width = 'fill',
  8. layout_height = 'fill',
  9. background = '#ffffff',
  10. {
  11. TextView,
  12. text = '我的主页',
  13. textSize = '20sp',
  14. textColor = '#333333',
  15. layout_gravity = "center|bottom",
  16. layout_marginTop = '35px',
  17. },
  18. {
  19. TextView,
  20. layout_width = '97.4%w',
  21. layout_height = '5px',
  22. layout_marginTop = '10dp',
  23. layout_marginBottom = '10dp',
  24. layout_gravity = 'center',
  25. backgroundColor = '#FFBEBEBE'
  26. },
  27. {
  28. GridView,
  29. id = "list",
  30. numColumns = 3,
  31. layout_width = 'fill',
  32. layout_height = 'fill',
  33. horizontalSpacing = "3dp",
  34. verticalSpacing = "0dp",
  35. layout_gravity = "center",
  36. OverScrollMode = 2
  37. }
  38. }
  39. webView.addView(loadlayout(layout))
  40. function 布局边框(边框粗细, 边框颜色, 背景颜色, 圆角大小)
  41. import "android.graphics.drawable.GradientDrawable"
  42. drawable = GradientDrawable()
  43. drawable.setShape(GradientDrawable.RECTANGLE)
  44. drawable.setStroke(边框粗细, tonumber(边框颜色))
  45. drawable.setColor(tonumber(背景颜色))
  46. drawable.setCornerRadius(圆角大小)
  47. return drawable
  48. end
  49. item = {
  50. LinearLayout,
  51. layout_height = "48dp",
  52. layout_width = "fill",
  53. {
  54. LinearLayout,
  55. layout_height = "fill",
  56. layout_width = "fill",
  57. layout_margin = "5dp",
  58. BackgroundDrawable = 布局边框(4,0x66000000, 0x00000000, 15),
  59. {
  60. TextView,
  61. id = "name",
  62. layout_height = "fill",
  63. layout_width = "fill",
  64. gravity = "center",
  65. textColor = "#FF000000"
  66. },
  67. {
  68. TextView,
  69. id = "tools",
  70. layout_width = "0dp",
  71. layout_height = "0dp"
  72. },
  73. {
  74. TextView,
  75. id = "url",
  76. layout_width = "0dp",
  77. layout_height = "0dp"
  78. }
  79. }
  80. }
  81. adapter = LuaAdapter(activity, item)
  82. function getToolsText(v)
  83. return v.Tag.tools and v.Tag.tools.text or ""
  84. end
  85. list.onItemClick = function(l, v, p, i)
  86. local toolsText = getToolsText(v)
  87. local urlText = v.Tag.url.text
  88. if urlText:find '://' then
  89. print("正在加载\n".. v.Tag.name.text)
  90. 子页面('安卓',urlText)
  91. elseif toolsText:find 'diantong' then
  92. print ('预防误碰,请长按!')
  93. elseif toolsText:find 'zhinanzhen' then
  94. print ('预防误碰,请长按!')
  95. else
  96. WEB小程序(toolsText)
  97. end
  98. end
  99. list.onItemLongClick = function(l, v, p, i)
  100. if v.Tag.url.text:find '://' then
  101. if v.Tag.name.text:find '多功能工具' or v.Tag.name.text:find '本地' then
  102. print("软件内置工具,不支持使用系统默认浏览器打开😃!")
  103. return true
  104. end
  105. print("使用系统默认浏览器打开\n".. v.Tag.url.text)
  106. 调用浏览器(v.Tag.url.text)
  107. return true
  108. elseif v.Tag.tools.text:find 'diantong' then
  109. 手电筒()
  110. return true
  111. elseif v.Tag.tools.text:find 'zhinanzhen' then
  112. WEB小程序('zhinanzhen')
  113. return true
  114. else
  115. print ('暂时没有添加长按功能噢😃!')
  116. return true
  117. end
  118. end
  119. list.Adapter = adapter
  120. local dataList = {
  121. -- tools相关数据
  122. {name = "更多应用", tools = "yingyong"},
  123. {name = "编辑器", tools = "bianjiqi1"},
  124. {name = "音乐播放器", tools = "music"},
  125. {name = "手电筒", tools = "diantong"},
  126. {name = "指南针", tools = "zhinanzhen"},
  127. -- url相关数据
  128. {name = "永硕网盘", url = "http://cgb0523.ysepan.com/"},
  129. {name = "本地搜索", url = "http://localhost:44444/jx/so/"},
  130. {name = "多功能工具", url = "file:///android_asset/index.html"},
  131. {name = "三维空间免费", url = "http://txcgb.web3v.work/dh/"},
  132. {name = "三维空间\nsan.txcgb.site", url = "http://san.txcgb.site/jx/so/"},
  133. {name = "web10301\nm.txcgb.site", url = "https://m.txcgb.site/jx/so/"},
  134. {name = "web10613\nmov.txcgb.site", url = "https://mov.txcgb.site/jx/so/"},
  135. {name = "三维空间\ntxcgb.v2free.cf", url = "http://txcgb.v2free.cf/jx/so/"},
  136. {name = "web10301\nyu.v2free.cf", url = "https://yu.v2free.cf/jx/so/"},
  137. {name = "web10613\nmov.v2free.cf", url = "https://mov.v2free.cf/jx/so/"}
  138. }
  139. for _, data in ipairs(dataList) do
  140. adapter.add(data)
  141. end