Skip to content

Commit a20927b

Browse files
committed
add ListViewExample1
1 parent 9e655e9 commit a20927b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

Example/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import HuaWeiRefreshControl from './HuaWeiRefreshControl'
1818
import ListViewExample from './ListViewExample'
1919
import FlatListExample from "./FlatListExample";
20+
import ListViewExample1 from './ListViewExample1'
2021
const instructions = Platform.select({
2122
ios: 'Press Cmd+R to reload,\n' +
2223
'Cmd+D or shake for dev menu',
@@ -43,7 +44,7 @@ type Props = {};
4344
export default class App extends Component<Props> {
4445
render() {
4546
return (
46-
<FlatListExample/>
47+
<ListViewExample1/>
4748
);
4849
}
4950
}

Example/ListViewExample1.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, {Component} from 'react';
2+
import {StyleSheet, View, Text,ListView,ScrollView} from 'react-native';
3+
import PropTypes from 'prop-types';
4+
import HuaWeiRefreshControl from './HuaWeiRefreshControl';
5+
6+
export default class ListViewExample1 extends Component {
7+
constructor(props){
8+
super(props);
9+
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
10+
this.state = {
11+
dataSource: ds.cloneWithRows(['row 1', 'row 2','row 3','row 4','row 5','row 6','row 7','row 8']),
12+
};
13+
}
14+
_onRefresh=()=>{
15+
setTimeout(()=>{
16+
this._hw && this._hw.finishRefresh()
17+
},1000)
18+
}
19+
render() {
20+
return (
21+
<View style={{flex: 1}}>
22+
<ListView
23+
refreshControl={<HuaWeiRefreshControl
24+
ref={ref=>this._hw = ref}
25+
onRefresh={this._onRefresh}
26+
/>}
27+
dataSource={this.state.dataSource}
28+
renderRow={(rowData) => <Text onPress={()=>alert(111)} style={{height:100}}>{rowData}</Text>}
29+
/>
30+
</View>
31+
)
32+
}
33+
}

0 commit comments

Comments
 (0)