优化listview

This commit is contained in:
wushenghua
2016-02-23 16:54:27 +08:00
parent 3070f11460
commit 2235f5d95f
4 changed files with 8 additions and 16 deletions
+1 -3
View File
@@ -119,8 +119,6 @@ getInitialState: function() {
);
},
pushInfo:function(index){
console.log(this.state.dataSource.getRowData(0,index))
this.props.navigator.push({
title: 'New Page',
component: <InfoPage movie={this.state.dataSource.getRowData(0,index)}> </InfoPage>
@@ -129,7 +127,7 @@ getInitialState: function() {
renderLoadingView:function(){
if (!this.state.isLoadingFail) {
return (
<TouchableOpacity onPress={() =>this.fetchData()} style={styles.container} >
<TouchableOpacity onPress={() =>this.fetchData} style={styles.container} >
<View style={styles.container}>
<Text>
{'点击刷新'}
+4 -6
View File
@@ -60,8 +60,6 @@ export default class MyListView extends Component{
myfetchData(){
this.setState({isLoading:true,isLoadingFail:false});
this.props.fetchData().then((responseData)=>{
console.log('接受到数据');
console.log(responseData);
this.setState({
isLoading: false,
isLoadingFail: false,
@@ -104,13 +102,13 @@ export default class MyListView extends Component{
pushInfo(index){
this.props.navigator.push({
title: 'New Page',
component: <InfoPage movie={this.state.dataSource.getRowData(0,index)}> </InfoPage>
}).bind(this);
component: <InfoPage movie={this.props.dataSource.getRowData(0,index)}> </InfoPage>
});
}
renderLoadingView(){
if (this.state.isLoadingFail) {
return (
<TouchableOpacity onPress={() =>this.myfetchData.bind(this)} style={styles.container} >
<TouchableOpacity onPress={() =>this.myfetchData()} style={styles.container} >
<View style={styles.container}>
<Text>
{'点击刷新'}
@@ -141,7 +139,7 @@ export default class MyListView extends Component{
return (
<View style={styles.container} key={rowID}>
<TouchableOpacity onPress={(rowID) =>this.pushInfo.bind(this)} style={styles.container} >
<TouchableOpacity onPress={()=>{this.pushInfo(rowID)}} style={styles.container} >
<Image
source={{uri: movie.imageurl}}
style={styles.thumbnail}/>
+3 -6
View File
@@ -39,10 +39,7 @@ export default class MyListViewDemo extends Component{
<Text style={styles.title}>
随机
</Text>
),
event: function() {
this.fetchData();
}.bind(this)
)
}
})
}
@@ -59,7 +56,7 @@ export default class MyListViewDemo extends Component{
fetch(url)
.then((response) => response.json())
.catch((error) => {
reject(err);
reject(error);
})
.then((responseData) => {
if(responseData){
@@ -82,7 +79,7 @@ export default class MyListViewDemo extends Component{
<MyListView
dataSource={this.state.dataSource}
refreshTitle={'测试一下刷新'}
navigator={this.props.navigator}
{...this.props}
fetchData={this.fetchData.bind(this)}/>
);
}
-1
View File
@@ -128,7 +128,6 @@ class TabBarNavigator extends Component {
};
}
setNavItems(config) {
console.log('setting nav items. currentTabIndex: ' + this.currentTabIndex);
if (this.currentRoute.isRoot) {
this.rootNavigatorItems[this.state.currentTabIndex] = config;
this.forceUpdate();