如何在 react-native 中实现 Horizo​​ntal ListView 或 FlatList

How to do an Horizontal ListView, or FlatList in react-native

我正在寻找一种在 React-native 中制作水平 ListView 或 FlatList 的方法。

喜欢下图:

我尝试使用 Flex 来管理它,但结果很奇怪,而且总是使用垂直 ListView

如果你有任何想法,请告诉我。

此致,

答案是将水平属性设置为true

是的,现在在文档中有描述:https://reactnative.dev/docs/flatlist#horizontal

显然 FlatList 是 ScrollView 的子级,所以他得到了 Horizo​​ntal Bool。

  <FlatList
    horizontal={true}
    data={DATA}
    renderItem={renderItem}
    keyExtractor={(item) => item.id}
    extraData={selectedId}
  />

再见

感谢您最后的回答,ListView 现已弃用。

FlatList 的解决方案:

<FlatList
    style={styles.videos_flatList}
    horizontal={true}
    data={data1}
    renderItem={({item}) => 
        <RowItem/>
    }

    ItemSeparatorComponent={() => {
        return (
            <View
                style={{
                height: "100%",
                width: 20,
                backgroundColor: "#CED0CE",

                }}
            />
        );
    }}

    keyExtractor={(item, index) => index.toString()}
/>