2017-03-15 15 views
7

Native Base kütüphanesi ile React Native kullanıyorum. Klavyenin açık olması durumunda, Native Base 'ListItem (TouchableOpacity öğesine eşdeğer)' ye ateş etmek için bir onPress olayına ihtiyacım var.React Native Çalışmak için üzerine çift tıklamak zorundadır.

Şimdi klavyeyi kapatmak için bir kez tıklatıp ListItem'e basabilirim. Aşağıda

İçerik ScrollableView eşdeğerdir:

<Content keyboardShouldPersistTaps='always' keyboardDismissMode='on-drag'> 
    <List> 
    <ListItem style={styles.inspectionsItemDivider} itemDivider> 
     <TextInput 
     autoFocus={true} 
     ref={(input) => { this.titleSearch = input }} 
     placeholder='Start typing...' 
     multiline={true} 
     onChangeText={this.setSearchText.bind(this)} 
     value={this.getSearchValue()}/> 
    </ListItem> 
    <View style={styles.searchContainer}> 
     <Text style={styles.recentText}>Recommended Descriptions</Text> 
     <List dataArray={this.state.searchedDescriptions} 
     renderRow={(description) => 
     <ListItem button onPress={() => this.setInformationDescription(description)}> 
      <Text>{description}</Text> 
     </ListItem> 
     </List> 
    </View> 
    </List> 
</Content> 

cevap

16

Aslında bunu anladım.

<Content keyboardShouldPersistTaps='always' keyboardDismissMode='on-drag'> 
    <List> 
    <ListItem style={styles.inspectionsItemDivider} itemDivider> 
     <TextInput 
     autoFocus={true} 
     ref={(input) => { this.titleSearch = input }} 
     placeholder='Start typing...' 
     multiline={true} 
     onChangeText={this.setSearchText.bind(this)} 
     value={this.getSearchValue()}/> 
    </ListItem> 
    <View style={styles.searchContainer}> 
     <Text style={styles.recentText}>Recommended Descriptions</Text> 
     <List keyboardShouldPersistTaps='always' dataArray={this.state.searchedDescriptions} 
     renderRow={(description) => 
     <ListItem button onPress={() => this.setInformationDescription(description)}> 
      <Text>{description}</Text> 
     </ListItem> 
     </List> 
    </View> 
    </List> 
</Content> 
-1

şimdi bir hafta boyunca bu aynı şey sıkışmış edilmiştir.

Bir Content etiketinde ListItems aracılığıyla filtrelediğim bir SearchBox'um var. Klavyesiz bile, onPress eylemini tetiklemek için iki kez tıklamak zorundayım.

<Header searchBar rounded style={{ paddingTop: 0, height: 45 }}> 
      <Item> 
       <Icon name="search" /> 
       <Input 
        placeholder="Search" 
        ref={input => this.searchbox = input} 
        value={term} 
        onChangeText={term => this.setState({term})} /> 
       <Icon active name="close-circle" onPress={() => { 
        this.setState({ term: '' }); 
        this.searchbox._root.focus(); 
       }} /> 
      </Item> 
     </Header> 
     <Content> 
      <List dataArray={ 
      products.filter(product => 
       product.description 
       .toLowerCase() 
       .indexOf(this.state.term.toLowerCase()) >= 0 
      ) 
      } renderRow={product => 
      <ListItem onPress={() => Actions.productdetail({ product })}> 
       <Body> 
       <Text>{product.description}</Text> 
       <Text note>{product.size}</Text> 
       </Body> 
       <Right> 
       <Text note>{product.item_number}</Text> 
       </Right> 
      </ListItem> 
      } /> 
     </Content> 
+0

deneyin 'her zaman' İçerik ve Liste etiketlerine desteklemek keyboardShouldPersistTaps = ekleyerek: I = 'hep' İçerik etiketi ek olarak, benim Listesine desteklemek keyboardShouldPersistTaps ekledi. –

+0

Bu, sorunun cevabı değildir. –