ListView渲染一个TextInput,如何显示键盘

时间:2017-05-02 07:36:00

标签: react-native

出于某种原因,我必须在ListView中呈现TextInput

renderRow(rowData,sectionID,rowID,highlightRow) {if(sectionID == '搜索') {
    return (
      <View style={ {flexDirection: 'row', justifyContent: 'space-between',backgroundColor: '#C0C0C0', alignItems: 'center'}}>
        <View style={ [styles.inputWrapper, {justifyContent: this.state.inputJustifyContent}]}>
          <KeyboardAvoidingView behavior={"padding"}>
            <TextInput  style={[styles.inputInner, { width:this.state.inputWidth}] }
                        placeholder="城市名称或首字母"
                        clearButtonMode="while-editing"
                        keyboardType="default"
                        caretHidden={ this.state.caretHidden }
                        onFocus={ this.inputOnFocus.bind(this) }
                        onBlur={ this.inputOnBlur.bind(this) }/>
          </KeyboardAvoidingView>
        </View>
        <TouchableOpacity style={{flex: 1}} >
          <Text onPress={ this.inputCancel.bind(this) } style={styles.inputCancel}>取消</Text>
        </TouchableOpacity>
      </View>
    )
  }
inputOnFocus() {
   let ds = new ListView.DataSource({
            rowHasChanged: (r1, r2) => r1 !== r2,
            sectionHeaderHasChanged: (s1, s2) => s1 !== s2
        });
  this.setState({
    inputWidth: pxTodp(600),
    inputJustifyContent: 'flex-start',
    dataSource: ds.cloneWithRowsAndSections(this.getRows()),
  })
}

但是在renderRow功能中,我不知道为什么键盘没有反应。

也许我应该像InputOnFocus一样创建一个新的DataSource来呈现状态?

0 个答案:

没有答案