所以我使用的是 React Native 和 Realm。基本上我想在 Realm 查询开始之前显示一个指示器,然后在它完成时隐藏它。但指标似乎没有出现。我对 React Native 的理解还是新的!
这是我到目前为止所拥有的:
<SegmentedControlIOS
values={['Matched', 'Last Active', 'Distance', 'Age']}
momentary={false}
tintColor={'#DB4C2C'}
style={{
width: width,
marginTop: 10
}}
selectedIndex={this.state.scIndex}
onValueChange={(value) => {}}
onChange={(event) => {
console.log("CHANGE")
var selectedIndex = event.nativeEvent.selectedSegmentIndex;
this.sortMatches(selectedIndex)
this.setState({
scIndex: event.nativeEvent.selectedSegmentIndex
})
}}/>
sortMatches(index) {
this.setState({loading: true})
var sortMatches = null;
if (index == 0) {
sortedMatches = this._sort_matched()
} else if (index == 1) {
sortedMatches = this._sort_last_active()
} else if (index == 3) {
sortedMatches = this._sort_birthdate()
}
let dataSource = ds.cloneWithRows(sortedMatches)
this.setState({dataSource: dataSource, loading: false})
}
<ActivityIndicator
animating={this.state.loading}
style={[styles.centering, {height: 30, paddingTop: 20}]}
size="small"/>