|
| 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