开发者

Best way to have i18n autocompletetextview

AutoCompleteTextView works great with a string array defined in your resources. However if you use the standard example for the count开发者_StackOverflow社区ries list as seen on the android developer site the list will be different for each locale.

Assume you would have to display the i18n country names but under the hood you have to track the ISO country code. So the autocompletion has to be country specific (locale) and list sorted correctly.

At the moment I am hauling up list collections of a of Country pojos with isocode and description attributes for the locale. For the autocompletelist I use the descriptions in their own array and then when needing the isocode I do a reverse lookup in the collection.

There gotta be a better pattern for this sort of thing though. Similar use case it around spinners. Any recommendations?


The Adapter doesn't have to return a list of strings. If you have a list collection of Country pojos, just have the adapter use it (ListAdapter for instance). You may want to do your own implementation of filtering or have Country.toString() return something suitable for sorting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜