简体   繁体   English

单击项目后在FlatList中对本机更改颜色做出反应(instagram之类的)

[英]react native change color one item in FlatList after click item (instagram like)

react native change color one item in FlatList after click item 单击项目后在FlatList中对本机更改颜色做出反应

<FlatList
      data={this.state.posts}
      renderItem={this.renderItem.bind(this)}
      keyExtractor={(item, index) => index}
      ListEmptyComponent={()=> <Spinner />}
      onEndReached={this.handleLoadMore.bind(this)}
      onEndReachedThreshold={0.5}
      initialNumToRender={1}
/>

after render list click on item and change color item: 渲染列表后,单击项目并更改颜色项目:

renderItem({item}){
return (
<Button transparent>
   <TouchableOpacity
       onPress={()=>this.likeSave(item.id) }
   >
   <Icon name="heart" size={30} style={{color:likeColor}} />
    </TouchableOpacity>
</Button>
}

after click Icon heart change color Icon heart to red 单击后,图标心会更改颜色图标心变为红色

The multi select example in Flatlist React Native documentation can explain how to solve your problem. Flatlist React Native文档中的多选示例可以说明如何解决您的问题。 Check it out here Flatlist React Native Component 在这里检查它Flatlist React Native Component

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 React Native 的平面列表中更改所选项目的颜色? - How can I change the color of selected item in flatlist in React Native? react-Native更改平面列表中所选项目的颜色 - react-Native Change color on selected item in flatlist 项目后反应原生动画平面列表项目 - react native animated flatlist item after item 在 React Native 中单击位于它之外的按钮更改 Flatlist 的项目 - Change Item of Flatlist on click of button which is outside of it in react native React Native - 单击 Flatlist 的项目(搜索列表后) - React Native - Click item of Flatlist (after searched the list) 反应原生,select 来自平面列表的一项 - React native, select one item from flatlist 渲染后如何在不刷新 React Native 上的其他项目的情况下更改 FlatList 项目的 state - How to change state of FlatList item after rendered without refreshing other item on React Native React Native:更改并保留 Flatlist 内仅 onPressed 项目的背景颜色 - React Native: Change and keep the background color of only onPressed item inside Flatlist 在React Native中按下按钮时如何更改FlatList项目背景颜色 - How can i change the FlatList item background color when button is pressed in React Native 如何在FlatList react-native中更改每个列表项的不同颜色 - How to change different color of each list item in FlatList react-native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM