简体   繁体   中英

How to implement your own hints in android application

I have prepared list with about 200 words for my application. There are only names of mountain peaks (Polish) like Rysy, Giewont, Ornak, etc.

I would like to get this names as hints while user is writing a name of a peak.

For example - after running my app, user wants to find a Giewont but he doesn't know how to write it, when he apply G, there are suggestions for him "Giewont", "Grzes" and more. If he apply Gi, then second hint - "Grzes" is not seen anymore.

Is there a possibility to implement something like this dynamically?

Also is there an option to remove "Android keyboard hints" in app or is this possible only in Android Phone?

You can do this with AutoCompleteTextView. AutoCompleteTextView receives an ArrayAdapter object for suggestions like this:

val hints = {the name of peaks}
val adapter = ArrayAdapter<String> (context, android.R.layout.select_dialog_item, hints)
autoCompleteTextView.threshold(/* an integer for the threshold */ 1)
autoCompleteTextView.adapter(adapter)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM