-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathListViewExample1.js
More file actions
78 lines (77 loc) · 1.95 KB
/
Copy pathListViewExample1.js
File metadata and controls
78 lines (77 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React, {Component} from 'react';
import {FlatList, StyleSheet, Text, View, ViewPagerAndroid} from 'react-native';
import HuaWeiRefreshControl from './HuaWeiRefreshControl';
export default class ListViewExample1 extends Component {
constructor(props) {
super(props);
this.state = {
data: [
'row 1',
'row 2',
'row 3',
'row 4',
'row 5',
'row 6',
'row 7',
'row 8',
],
};
}
_onRefresh = () => {
setTimeout(() => {
this._hw && this._hw.finishRefresh();
}, 1000);
};
render() {
return (
<View style={{flex: 1, backgroundColor: 'blue'}}>
<FlatList
// nestedScrollEnabled
style={{
...StyleSheet.absoluteFillObject,
flex: 1,
borderRadius: 9,
paddingTop: 150,
backgroundColor: 'red',
}}
contentContainerStyle={{flex: 0, paddingBottom: 150}}
renderHeader={() => (
<ViewPagerAndroid style={styles.viewPager} initialPage={0}>
<View style={styles.pageStyle} key="1">
<Text>First page</Text>
</View>
<View style={styles.pageStyle} key="2">
<Text>Second page</Text>
</View>
</ViewPagerAndroid>
)}
refreshControl={
<HuaWeiRefreshControl
ref={ref => (this._hw = ref)}
onRefresh={this._onRefresh}
/>
}
data={this.state.data}
renderItem={({item}) => (
<Text
key={item}
onPress={() => alert(111)}
style={{height: 100, borderColor: 'black', borderWidth: 1}}>
{item}
</Text>
)}
/>
</View>
);
}
}
const styles = StyleSheet.create({
viewPager: {
flex: 1,
height: 300,
},
pageStyle: {
alignItems: 'center',
padding: 20,
},
});