• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16@Entry
17@Component
18struct ListRootView {
19
20    dataArrayList:string[] = [
21        "item0", "item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8", "item9",
22        "item10", "item11", "item12", "item13", "item14", "item15", "item16", "item17", "item18", "item19",
23        "item20", "item21", "item22", "item23", "item24", "item25", "item26", "item27", "item28", "item29",
24    ];
25
26    @State listidx:number = 50;
27
28    build(){
29        Column(){
30            Text('--------------- List :foreach test --------------->')
31            Text("index:" + this.listidx)
32            List(){
33                ForEach(
34                    this.dataArrayList,
35                    (item) => {
36                        ListItem(){
37                            Text(item)
38                        }
39                        .backgroundColor(0x6495ED).height(50)
40                        .onClick(() => {
41                            this.listidx ++;
42                        })
43                    },
44                    (item) => item
45                )
46            }
47            .height(600).width(500)
48            .divider({ strokeWidth: 2, color:"#FF00ff"}).scrollBar(BarState.Off)
49            .onReachStart(() => {
50                console.info("list-demo reachStart ");
51            })
52            .onReachEnd(() => {
53                console.info("list-demo reachEnd ");
54            })
55            .onScrollStop(() => {
56                console.info("list-demo scrollStop ");
57            })
58            .onScroll((offset: number, state: ScrollState) => {
59                console.info('list-demo scroll:offset:' + offset + ",State:" + state)
60            })
61        }
62    }
63}
64