Change React Native Image source on click

后端 未结 2 1862
闹比i
闹比i 2021-01-03 07:03

I currently have an Image wrapped inside of a TouchableOpacity tag. The image is of a sound icon, and when the user clicks it, I would like the icon to switch between the \"

2条回答
  •  余生分开走
    2021-01-03 07:27

    I'm using the following way and its working fine.

    class HomeScreen extends Component {
      static navigationOptions = {
        header: null,
    };
    
    constructor() {
        super();
    
        this.state = {
          flagImage:true
        };
    }
    
    render(){
        let imageXml = ;
        return (
          
            
              
    
              
    
              
            
          
        );
      }
    }
    
    changeImage() {
    
       this.setState({
          flagImage:!this.state.flagImage
        });
    
    }
    

提交回复
热议问题