【发布时间】:2011-07-07 03:45:00
【问题描述】:
我完全遵循AutoCompleteTextView tutorial。涉及软键盘时布局会出错。
在下拉菜单中点击(选择或滚动)后,布局被破坏:
我在 AutoCompleteTextView 上尝试了各种属性组合,但似乎都没有。我也尝试设置windowSoftInputMode。下拉菜单总是在文本框上方弹出,并永远保留在那里。
横向,布局没问题:
标准的自动完成功能没用吗?我应该使用不同的/自己编写吗?
我使用的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Country" />
<AutoCompleteTextView android:id="@+id/autocomplete_country"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"/>
</LinearLayout>
MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES);
textView.setAdapter(adapter);
}
【问题讨论】:
-
你学了什么教程?请向我们展示您的一些代码。
-
所有代码都在链接教程中。我不想复制它,但是好的,我在这里复制了它。
-
你在什么设备上运行这个?
-
HTC Desire,但它在模拟器中的行为也是一样的。