2017-12-22 6 views
2

を示しています。画像ビューを作成し、私はこの1つのようなビューを作成するより

enter image description here

私は、すべてのデータがこれらのサムネイルを含め来ているFlatlistを使用しています。このサムネイルは、画像の名前と表示を取得するオブジェクトの配列です。

:今、私はこのようにそれを実装しようとしています

私はすべての私のデータが来ているFlatList内にこれを使用したいか、私はこの機能を実装するためのダミーコードが必要ですが、ネイティブ

を反応させます

<View style={{flexDirection:'row'}}> 
      {data.gallery.map((each,index)=>{ 
       console.log('thubnails ******* ', each); 
       <Image source={{uri: Connection.getMedia()+each.name}} style={{height:Constants.BaseStyle.DEVICE_HEIGHT/100 * 10, width:Constants.BaseStyle.DEVICE_WIDTH/100 * 10}} resizeMode='stretch' /> 
      })} 
      </View> 

data.gallaryの中にはすべてのサムネイルが存在し、データは小道具から来ています。

答えて

1

上記のサンプルコード。

Insideは、をレンダリング:

<FlatList 
    data={this.props.sampleData} // sample data should be a array of objects 
    renderItem={this.renderImage} 
    /> 

renderImage機能

renderImage = ({ item }) => (
    <Image source={{ uri: Connection.getMedia()+item.name }} 
     style={{height:Constants.BaseStyle.DEVICE_HEIGHT/100 * 10, 
     width:Constants.BaseStyle.DEVICE_WIDTH/100 * 10}} 
     resizeMode='stretch' 
    /> 
); 

あなたはまた、デバイスの高さと幅を取得するための寸法を使用することができます。

関連する問題