React Native或NativeBase Picker可以包含包含图像的项目吗?
问题描述:
我是新来的智能手机程序设计和加入了使用本地做出反应和NativeBase项目。React Native或NativeBase Picker可以包含包含图像的项目吗?
我想包括在一个选择器,它似乎并不像一个外来概念,每个项目的图像/图标,但它似乎并没有得到支持,我无法找到任何人讨论这样做在SO或谷歌搜索。
我已经尝试了几种方法在<Picker.Item>
和</Picker.Item>
内添加东西,但似乎任何东西都被忽略。
是否有可能还是有不同的方法做什么我想用这些框架?
答
你可以试试这个包
https://github.com/sohobloo/react-native-modal-dropdown
完整的例子,你可以点击这里
https://github.com/sohobloo/react-native-modal-dropdown/blob/master/example/index.js
使用是这样的
_dropdown_2_renderRow(rowData, rowID, highlighted) {
let icon = highlighted ? require('./images/heart.png') : require('./images/flower.png');
let evenRow = rowID % 2;
return (
<TouchableHighlight underlayColor='cornflowerblue'>
<View style={[styles.dropdown_2_row, {backgroundColor: evenRow ? 'lemonchiffon' : 'white'}]}>
<Image style={styles.dropdown_2_image}
mode='stretch'
source={icon}
/>
<Text style={[styles.dropdown_2_row_text, highlighted && {color: 'mediumaquamarine'}]}>
{`${rowData.name} (${rowData.age})`}
</Text>
</View>
</TouchableHighlight>
);
}
最终产品例子是是这样的:
的所有版权属于: https://github.com/sohobloo
你的意思是这样的模态下拉? https://github.com/sohobloo/react-native-modal-dropdown –
@GaneshCauda:这看起来完全像我所期待的,如果你想提交它作为一个答案。 – hippietrail
肯定乐意为你们:),请让我知道,如果你有在执行这一 –