根据我从服务器返回的响应,我想从下面的响应中更改字段friends_status
状态的按钮
{
"responseHeader": {
"type": "314",
"status": "200",
"message": "Successfully found the profile"
},
"neighbourProfile": [{
"friends_status": "210",
},
{
"friends_status": "217",
},
{
"friends_status": "219",
},
{
"friends_status": "200",
}
]
}
我想更改按钮文本以及按钮。如何用图像替换按钮
更新:
if(neighbours.friend_status == '219'){
<Button color={'#00BFA5'} title="Add"
onPress={console.log('clicked')}/>
}
else if(neighbours.friend_status == '208'){
<Button color={'#ffffff'} title={"Add"} onPress={console.log('clicked')}/>
}
else if(neighbours.friend_status == '216')
{
<TouchableOpacity>
<Image source={require('../Images/ic_reject.png')}/>
<Image source={require('../Images/ic_request_accept.png')}/>
</TouchableOpacity>
}
else if(neighbours.friend_status == '221'){
<TouchableOpacity>
<Image source={require('../Images/ic_reject.png')}/>
<Image source={require('../Images/ic_request_accept.png')}/>
</TouchableOpacity>
}
要使<Image />
成为<Button />
,你可以放置包装<Touchable />
的图像:
<View style={styles.buttonStyle}>
<TouchableWithoutFeedback onPress={() => {}}>
<Image source={{uri: YOUR_IMAGE_URI}} />
</TouchableWithoutFeedback>
</View>
含有内容的qazxsw poi(和其他Touchables)非常类似于带有自定义内容的qazxsw poi。
检查qazxsw poi,qazxsw poi,qazxsw poi选择一个适合您需求的。
我建议你创建自己的按钮组件,你可以将你的friends_status数据作为道具传递给组件,而不是你可以这样做:
<TouchableWithoutFeedback />
}
如果我的回答不明确,请随时向我提出任何问题。您还可以通过以下方式获取新的道具价值:
<Button />
}