Skip to content

Commit da49c75

Browse files
author
野松
committed
request update: udpate demo
1 parent f654bb1 commit da49c75

File tree

3 files changed

+140
-29
lines changed

3 files changed

+140
-29
lines changed

Android/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build
66
gradle
77
local.properties
88
*.iml
9+
build/intermediates/dex-cache/cache.xml

Android/LuaViewDemo/assets/test/UI_PagerIndicator.lua

-29
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,6 @@ local SCREEN_WIDTH = System.screenSize()
77
function createCircleIndicator()
88
local indicator = PagerIndicator()
99
indicator.size(SCREEN_WIDTH / 2, 100)
10-
-- indicator.pageColor(0xffff0000)
11-
-- indicator.fillColor(0xff0000ff)
12-
-- indicator.radius(10)
13-
-- indicator.strokeWidth(4)
14-
-- indicator.strokeColor(0xff00aaaa)
15-
-- indicator.backgroundColor(0x33333333)
16-
indicator.alignCenter()
17-
return indicator
18-
end
19-
20-
function createSelfDefinedIndicator()
21-
local indicator = CustomPagerIndicator({
22-
Init = function(cell, pos, currentPos)
23-
cell.btn = Button()
24-
end,
25-
Layout = function(cell, pos, currentPos)
26-
cell.btn.size(50, 50)
27-
if (pos == currentPos) then
28-
cell.btn.text("+")
29-
-- cell.btn.setBackgroundColor(0xffff0000)
30-
else
31-
cell.btn.text(""..pos)
32-
-- cell.btn.setBackgroundColor(0xff00ff00)
33-
end
34-
end
35-
})
36-
indicator.size(SCREEN_WIDTH/2, 200)
37-
indicator.backgroundColor(0x33333333)
3810
indicator.alignCenter()
3911
return indicator
4012
end
@@ -65,7 +37,6 @@ pagerView = PagerView({
6537

6638
--活动指示器
6739
pagerView.indicator(createCircleIndicator())
68-
--pagerView.indicator(createSelfDefinedIndicator())
6940

7041

7142

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
--工具包引入
2+
require "kit/lv_kit"
3+
4+
w, h = System.screenSize()
5+
6+
window.backgroundColor(0, 1)
7+
8+
cellHeight = 100
9+
imageUrl1 = "http://gju2.alicdn.com/bao/uploaded/i1/10000073270926575/TB2fpg0cXXXXXb6XpXXXXXXXXXX_!!0-0-juitemmedia.jpg"
10+
imageUrl2 = "http://img4.duitang.com/uploads/item/201306/25/20130625045508_sairr.thumb.600_0.jpeg"
11+
12+
13+
14+
local vp = PagerView({
15+
PageCount = 4,
16+
Pages = {
17+
Title = function(pos)
18+
return "Title"
19+
end,
20+
Init = function(page, pos)
21+
local tableView = RefreshCollectionView {
22+
Section = {
23+
SectionCount = 2,
24+
RowCount = function(section)
25+
if(section == 1) then
26+
return 1
27+
else
28+
return 10
29+
end
30+
end
31+
},
32+
Cell = {
33+
Id = function(section, row)
34+
if(pos % 2 == 0) then
35+
if (section == 1) then
36+
return "HScroll"
37+
else
38+
return "ImageAndImage"
39+
end
40+
else
41+
if (section == 1) then
42+
return "Pager"
43+
else
44+
return "ImageAndImage"
45+
end
46+
end
47+
end,
48+
HScroll = {
49+
Size = function(section, row)
50+
return w, 100
51+
end,
52+
Init = function(cell, section, row)
53+
local scrollView = HScrollView()
54+
for i = 0, 10, 1 do
55+
local btn = Label()
56+
btn.text("BTN" .. i)
57+
btn.frame(i * 80, 0, 79, 100)
58+
btn.backgroundColor(0xff00ff00)
59+
scrollView.addView(btn)
60+
end
61+
scrollView.size(w, 100)
62+
scrollView.backgroundColor(0xffcccccc)
63+
cell.container= scrollView
64+
end,
65+
Layout = function(cell, section, row)
66+
end
67+
},
68+
Pager = {
69+
Size = function(section, row)
70+
return w, 100
71+
end,
72+
Init = function(cell, section, row)
73+
local vp = PagerView({
74+
PageCount = 10,
75+
Pages = {
76+
Title = function(pos)
77+
return "Title"
78+
end,
79+
Init = function(page, pos)
80+
page.icon = Button()
81+
end,
82+
Layout = function(page, pos)
83+
page.icon.text("测试按钮"..pos)
84+
page.icon.frame(0, 0, w, 100)
85+
end
86+
}
87+
})
88+
89+
vp.setBackgroundColor(0xaaaa0000)
90+
vp.setFrame(0, 0, w, 100)
91+
92+
cell.container = vp
93+
end,
94+
Layout = function(cell, section, row)
95+
end
96+
},
97+
ImageAndImage = {
98+
Size = function(section, row)
99+
return cellHeight
100+
end,
101+
Init = function(cell, section, row)
102+
cell.icon = Image()
103+
cell.icon2 = Image()
104+
end,
105+
Layout = function(cell, section, row)
106+
local cellWdith, cellHeight = cell.window.size()
107+
cell.icon.frame(0, 0, cellHeight, cellHeight)
108+
cell.icon.image(imageUrl1, function()
109+
print("imageLoaded-ImageAndImage-1", section, row)
110+
end)
111+
112+
113+
cell.icon2.frame(cellHeight + 10, 0, cellHeight, cellHeight)
114+
cell.icon2.image(imageUrl1, function()
115+
print("imageLoaded-ImageAndImage-2", section, row)
116+
end)
117+
end
118+
}
119+
}
120+
}
121+
tableView.frame(0, 0, w, h - 64)
122+
tableView.backgroundColor(0xffFFFF)
123+
124+
page.view = tableView
125+
126+
end,
127+
Layout = function(page, pos)
128+
end
129+
}
130+
})
131+
132+
vp.setBackgroundColor(0xaaaa0000)
133+
vp.setFrame(0, 0, w, h)
134+
135+
136+
137+
138+
139+

0 commit comments

Comments
 (0)