AutoCompleteTextView in react native compatible with both iOS and Android

核能气质少年 提交于 2019-12-10 13:29:17

问题


I need to implement AutoCompleteTextView in react native. The problem is that there is no such built-in component. All the modules and libraries available to mimic this feature is not completely similar. The main issue is the suggestions are not appearing over the view(like that of select box/picker). Even if it is then it is not behaving perfectly withKeyboardAvoidingView. The whole point is it is not working like native AutoCompleteTextView for Android

The other solution is using native UI element. But I want this component for both iOS and Android. Any help would be appreciated.

I want to achieve this option like tag user on the Facebook app

P.S.: Excuse the typos as I am using a mobile device.


回答1:


After searching a lot for available Libraries and module, I came up with my own implementation of custom AutoCompleteTextView.
I have created a gist for AutoCompleteTextView.
The idea behind:

*There is one input field on the focus of this field keyboard appears.

*When keyboard appears we calculate space from top to input field and from input field till the start of keypad area.

*Will display an absolute positioned scroll view Suggestion area on top or bottom of input field based on the space calculation above.

*When keyboard goes away we hide the suggestion area.

Suggestions are welcome on how to improve this thing.




回答2:


Here is the android native AutoCompleteTextView component - https://github.com/rajsuvariya/autocompletetextview - its a work in progress.



来源:https://stackoverflow.com/questions/49158554/autocompletetextview-in-react-native-compatible-with-both-ios-and-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!