AutoCompleteTextView在横向模式下的提示 [英] AutoCompleteTextView hints in landscape mode

查看:127
本文介绍了AutoCompleteTextView在横向模式下的提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在具有自定义适配器的应用程序中使用AutoCompleteTextView,它在纵向模式下完美运行.但是,在水平模式下,软件键盘占据了大部分屏幕,文本视图使用了覆盖按钮,而不是适配器提供的视图.

I'm using AutoCompleteTextView in my app with a custom adapter and it works perfect in portrait mode. In horizontal mode however the software keyboard takes most of the screen and text view uses overlay buttons instead of Views provided by the adapter.

我找不到有关此幕后工作方式的清晰文档.似乎在横向模式下,AutoCompleteTextView会绕过适配器的getView()方法,使用getItem()做一些肮脏的工作,并使用原始字符串来呈现项目本身.

I couldn't find a clear documentation about how this works behind the scenes. It seems that in landscape mode AutoCompleteTextView bypasses adapter's getView() method, does some dirty work using getItem() and renders items itself using raw strings.

更糟糕的是,在AutoCompleteTextView中似乎准确地显示了两个自动补全提示列表:同时显示标准下拉菜单和叠加按钮 (如果我们将imeOptions设置为flagNoExtractUi以防止AutoCompleteTextView在横向扩展,则很明显.)

To make things worse it seems that in AutoCompleteTextView is accualy presenting TWO lists of autocompletion hints: standard dropdown AND overlay buttons in the same time (this is well visible if we set imeOptions to flagNoExtractUi to prevent AutoCompleteTextView expanding in landscape).

我想在两种情况下都提供自己的视图-但到目前为止,我仅对下拉菜单进行了设置.是否有任何更改可为重叠列表提供自定义视图?

I'd like to supply my own Views in BOTH situations - but I managed to do it only for the drop down menu so far. Any changes to provide custom views for overlayed list?

很抱歉,由于排名低,我无法发布图片.如果有人需要,我可以寄给他们.

I'm sorry but I can't post images due to low ranking yet. I can send them if anyone needs them.

推荐答案

我自己遇到了此问题.就像您说的那样,在TextView中,TextView的自动完成提示基于getItem()的结果.在这种情况下,我真的看不到提供文本以外的任何方法的方法,但是要使正确的文本在横向显示,一种简单的解决方案是覆盖基于提示的对象的toString().

I just encountered this issue myself. Like you said, in landscape the TextView is basing its autocomplete hints on the result of getItem(). I don't really see a way to provide anything other than text in this scenario, but a simple solution to get the correct text to show in landscape is to override toString() for the object you are basing the hint on.

例如,在我的场景中,我使用一个Contact对象列表来填充自动填充提示,因此我在Contact类中覆盖了toString()使其显示"FirstName LastName",而不是像"Contact @ a2a6d4d3a5."

For instance, in my scenario I am using a list of Contact objects to populate my autocomplete hints, so I overrode toString() in my Contact class to get it to show "FirstName LastName" instead of a raw object representation like "Contact@a2a6d4d3a5."

这篇关于AutoCompleteTextView在横向模式下的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆