我如何在一个ListView项目的末尾添加一个按钮
How do I add a button to the end of items in a ListView in ReactNative?
这就是我所尝试的,但是"显示未链接的标签"出现在底部,而不是在最后一项之后。
render() {
return (
<View style={styles.container}>
<Text style={styles.title}> Settings Children </Text>
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData)=> <Text>{rowData}</Text>}
/>
<View style={styles.button}>
<Text style={styles.buttonText}>Show unlinked tags</Text>
</View>
</View>
)
}
查看图片!
你可以使用renderFooter在你的列表后面呈现视图。
renderFooter = () => {
return (
<View style={styles.button}>
<Text style={styles.buttonText}>Show unlinked tags</Text>
</View>
)
}
render() {
return (
<View style={styles.container}>
<Text style={styles.title}> Settings Children </Text>
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData)=> <Text>{rowData}</Text>}
renderFooter={this.renderFooter}
/>
</View>
)
}
TLDR: React native不提供按钮组件,使用这个https://github.com/ide/react-native-button
完整:
npm install react-native-button --save
则使用
import React, { Component } from 'react';
import Button from 'react-native-button';
export default class ExampleComponent extends Component {
constructor(props, context) {
super(props, context);
// ...
}
_handlePress() {
console.log('Pressed!');
}
render() {
return (
<View>
<View>
<ListView
dataSource={ this.state.dataSource }
renderRow={ (rowData) => <Text>
{ rowData }
</Text> } />
</View>
<View>
<Button
style={ { fontSize: 20, color: 'green' } }
styleDisabled={ { color: 'red' } }
onPress={ () => this._handlePress() }>
Press Me!
</Button>
</View>
</View>
);
}
}
相关文章:
- 我可以在json对象中添加一个函数吗
- 如果使用 lodash 将属性存在于另一个对象中,则向对象添加属性
- 单击更改图标并通过javascript添加一个css类
- fluxxor向一个flux实例添加一组以上的操作
- 当在Ember中点击一个项目时,我如何将一个活动类添加到项目列表中
- 如何在Angular单元测试中从另一个控制器的rootScope将方法添加到rootScope中
- 将添加一个相同类型的事件附加或覆盖以前添加的具有相同名称的事件
- angularjs移除焦点上的活动类并添加到下一个项目
- 使用jquery contains获取一个元素并添加类
- 有没有添加一个ng点击到md背景
- 如何为下拉列表的每个选项添加一个属性
- javascript函数将数据添加到屏幕,但随后被另一个函数覆盖
- 单击删除其中一个添加的行
- 几个jQuery日期选择器小部件,只向其中一个添加类
- 我想创建一个添加新表单的按钮
- Babel v6:我如何/可以编写一个添加新语法(即新运算符)的插件
- GWT SimplePager -为每个下一个和上一个添加历史记录
- 自动提交表单上的最大长度,-为现有的一个添加java脚本代码
- 如何在jquery中移除一个添加了类的类
- 动态更改URL,而不需要将前一个添加到历史堆栈