When i used ViewPagerAndroid as the ListView header, the ViewPagerAndroid can not present anything。
When android.support.v4.view.ViewPager#onMeasure() called , blow call stack has the problem:
android.support.v4.view.ViewPager#populate(int newCurrentItem)
View.getWindowToken() NOTE!! There returns null , so ViewPage#populate break !
I don't known why WindowToken is null ,please help me 。
This is test code :
/**
* @author jinzhaoyu
*/
'use strict'
var React = require('react-native');
var {
AppRegistry,
View,
Text,
ListView,
ViewPagerAndroid,
} = React;
class Home extends React.Component{
constructor(props){
super(props);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => {
r1 !== r2
},
});
var data = [];
for(var i =0;i<10;i++){
data.push("Row "+i);
}
this.state = {
list: this.dataSource.cloneWithRows(data),
};
}
_renderHeader(){
return (
<ViewPagerAndroid
style={{flex: 1,height:300}}
initialPage={0}>
<View style={{alignItems: 'center',justifyContent:'center',backgroundColor:'yellow'}}>
<Text style={{color:'red',fontSize:20}}>First page</Text>
</View>
<View style={{alignItems: 'center',justifyContent:'center',backgroundColor:'blue'}}>
<Text style={{color:'red',fontSize:20}}>Second page</Text>
</View>
<View style={{alignItems: 'center',justifyContent:'center',backgroundColor:'black'}}>
<Text style={{color:'red',fontSize:20}}>Third page</Text>
</View>
</ViewPagerAndroid>
);
}
_renderRow(rowData: string, sectionID: number, rowID: number){
return(
<View style={{backgroundColor:'gray',flex:1,height: 40}}>
<Text>{rowData}</Text>
</View>
);
}
render(){
//return this._renderHeader(); //this worked !!
//Flow code not work!
return (
<ListView dataSource={this.state.list}
renderHeader={this._renderHeader}
renderRow={this._renderRow}/>
);
}
}
AppRegistry.registerComponent('Home', () => Home);
Hey jinzhaoyu, thanks for reporting this issue!
React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
react-native or for more real time interactions, ask on Discord in the #react-native channel.+1 have the same problem on RN0.17...
So i used 'react-native-viewpager' https://github.com/race604/react-native-viewpager
+1 I have the same problem on RN0.19
ViewPagerAndroid cannot be used in ListView
I have resolved this problem.
add list prop:
removeClippedSubviews={false}
Cool ! That's works for me , Thanks a lot !
@coyer
Thanks, this works.
I got this problem。
removeClippedSubviews={false} it works. However, in my case I use ViewPager in a ListView backed by RecyclerView for performance purpose, it doesn't work. Any solutions?
Not working in 0.50.3
Most helpful comment
I have resolved this problem.
add list prop:
removeClippedSubviews={false}