Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gridview item clickable #26

Open
susylPearl opened this issue May 24, 2016 · 4 comments
Open

Gridview item clickable #26

susylPearl opened this issue May 24, 2016 · 4 comments

Comments

@susylPearl
Copy link

How to make gridview item clickable? is there any method to do that?

@alphasp
Copy link

alphasp commented May 24, 2016

You can wrap your view in one of the touchable components with onPress event below from react native https://facebook.github.io/react-native/docs/touchablehighlight.html

TouchableHighlight
TouchableNativeFeedback
TouchableOpacity
TouchableWithoutFeedback

@susylPearl
Copy link
Author

can we wrap gridview in such components? or we should wrap gridview items in such components?

@alphasp
Copy link

alphasp commented May 25, 2016

wrap gridview item

var React = require('react-native');
var {
  View,
  Text,
  TouchableHighlight
} = React;
var GridView = require('react-native-grid-view');
var myApp = React.createClass({
  render: function() {
    return (
      <GridView
        items={this.state.movies}
        itemsPerRow={3}
        renderItem={this.renderItem}
      />
    );
  },
  renderItem: function(item) {
    return (
      <TouchableHighlight onPress={this.handleOnPress}>
        <View>
          <Text>item</Text>
        </View>
      </TouchableHighlight>
  },
  handleOnPress: function() {
    console.log("pressed!")
  }
});

@susylPearl
Copy link
Author

Thanks, i have done it :) cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants