【发布时间】:2019-02-07 09:00:57
【问题描述】:
我正在尝试自动滚动我的平面列表,但是当我运行我的代码时,我无法自动滚动,如果我想手动滚动,它会在每 5 秒后到达索引 0 .. 这是我的所有平面列表代码及其 refs 函数
在构造函数中
this.flatList1=null;
并且在组件中会挂载
componentWillMount(){
setInterval(()=>{
if(this.flatList1!==null){
this.flatList1.scrollToOffset({ offset: 1 })
}
}, 5000);
}
<FlatList horizontal
data={this.state.getallvideos}
ref={flatList1 => { this.flatList1 = flatList1 }}
renderItem={({item}) =>
<TouchableOpacity onPress={this.playvideoinnetpage.bind(this,item.vd_link,item.vd_thumbnail,item.vd_id,item.vd_title)}>
<Card
containerStyle={{
padding:0,
width:180,
height:112,
backgroundColor:'#000',
borderColor:'#000',
marginTop:10,
marginLeft: 5,
marginRight:5,
marginBottom:5
}}
image={{uri:item.vd_thumbnail}}
imageStyle={'stretch'}
>
<View style={{position:'relative',bottom:75,}}>
<Text numberOfLines={1} style={{color:'#fff',fontWeight:'bold',fontSize:14}}> {item.vd_title}</Text>
</View>
</Card>
</TouchableOpacity>
}
/>
【问题讨论】:
-
@manahor reddy 是那个解决方案吗??
-
不,我只是正确地格式化了问题
-
谢谢..你有什么解决办法吗??
-
不,我不知道我来自android的java脚本。
-
好的,不过还是谢谢
标签: javascript android reactjs react-native react-native-flatlist