Tim*_*nen 5 java xml android android-edittext
我有一个标准的直接EditText,我想在这个EditText上显示字典建议,所以我在XML中做了这个:
<EditText
android:id="@+id/messaging_messageEdit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:layout_weight="85"
android:background="@drawable/clanz_edit_text_holo_dark"
android:ems="10"
android:hint="Type your message here..."
android:singleLine="true"
android:inputType="textAutoComplete"
android:textColor="#dedede" >
</EditText>
Run Code Online (Sandbox Code Playgroud)
我认为该inputType参数将处理自动字典视图.在我的手机(Nexus Android 5.1)上,字典视图显示但是空白.在Genymotion模拟器(Android 4.1.1)上它根本不显示.
我错过了什么?
如果您正在寻找AutoComplete TextView,这可以是一个解决方案.
<AutoCompleteTextView
android:id="@+id/from_station"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="@string/enter_start"
android:imeOptions="actionNext"
android:inputType="textNoSuggestions"
android:textColorHint="@color/transparent_black" />
Run Code Online (Sandbox Code Playgroud)
您还可以使用参数设置阈值.需要在运行时设置适配器值.