How to show AutoCompleteTextView suggestions in landscape orientation

ぐ巨炮叔叔 提交于 2019-12-23 09:01:01

问题


AutoCompleteTextView displays it's suggestions in a dropdown in the portrait mode.I would like to display suggestions either in a dialog or in a dropdown in the landscape mode,here the EditText and the keyboard go full screen.

Which layout should I use in the Adapter to display hints as a dialog in landscape mode. Im currently using android.R.layout.simple_dropdown_item_1line.


回答1:


In the layout where you defined your AutoCompleteTextView use android:imeOptions=flagNoExtractUi

The flag prevents the element from going full-screen when it is rotated to landscape mode.




回答2:


@vamsiampolu answer is correct but if you want to use same by using java, you can use

    itemautoTxt.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

where itemautoTxt is AutoCompleteTextView

hope this will helpful to others.




回答3:


Firstly, set this android:imeOptions="flagNoExtractUi" in XML.

Secondly, your dropdown may be under your keybord or above it. So it may not fit on screen - appear below or above the visible area of the screen. To fix this use android:dropDownAnchor="@id/your_view" to pin dropdown to the required view.

Thirdly, the dropdown may not appear on some devices or may appear unstable.



来源:https://stackoverflow.com/questions/19906647/how-to-show-autocompletetextview-suggestions-in-landscape-orientation

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