-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListJS.js
122 lines (89 loc) · 2.25 KB
/
ListJS.js
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
TouchableWithoutFeedback,
Image,
AppRegistry,
FlatList
} from 'react-native';
export default class ListJS extends Component {
constructor(props){
super(props);
this.state = {
datalist: ['11111111','22222222']
}
}
_test = (name) => {
alert(name);
}
cell = (item) => {
return <CellItem testName={item.item}
pressFunc={this._test}></CellItem>
}
render() {
return (
<FlatList style={{backgroundColor: 'yellow'}}
data={this.state.datalist}
// renderItem={({item}) => <Text>{item.key}</Text>}
renderItem={this.cell}
/>
)
}
}
class CellItem extends Component {
constructor(props){
super(props);
this.name = props.testName;
}
_test =() => {
this.props.pressFunc(this.name);
}
render (){
//Flex布局 - 常用布局 cell 图片 文本 箭头
return (
<View style={styles_cell.container}>
<Image style={styles_cell.leftImg} source={require('./img/iOS_boy.jpg')}></Image>
<TouchableWithoutFeedback onPress={this._test}>
<Text style={styles_cell.text}>{this.name}</Text>
</TouchableWithoutFeedback>
<Image style={styles_cell.rightImg} source={require('./img/arrow_list_common_right.png')}></Image>
</View>
)
}
}
const styles_cell = StyleSheet.create({
container: {
backgroundColor: 'yellow',
flexDirection: 'row',
alignItems: 'center',
marginTop: 50,
},
leftImg: {
marginLeft: 15,
width: 110,
height: 110,
},
text: {
flex: 1,
marginLeft: 10,
fontSize: 12,
color: 'black',
backgroundColor: 'red',
},
rightImg: {
marginRight: 15,
width: 15,
height: 15,
backgroundColor: 'blue',
},
})
const styles = StyleSheet.create({
container: {
backgroundColor: 'red',
marginTop: 10,
width: 100,
height: 100,
}
})