1
私はAutoCompleteTextViewを持っていて、フィルタを設定したいと思っています。タイプすると、テキストフィールドに1文字しか入力できません。私がコードからtextView.setFilters
を取り除くとうまくいきます。私はちょうどフィルターを持っていません。私はまた、android:textAllCaps="true"
私のXMLファイルで試して、それは動作しません。どんな助けも素晴らしいだろう、ありがとう。AutoCompleteTextViewフィルタが正しく機能しない
マイコード:@のpskinkのポストの助けを借りて
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.textfield);
String[] MyArray = getResources().getStringArray(R.array.myarray);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, MyArray);
textView.setFilters(new InputFilter[]{new InputFilter.AllCaps(), new InputFilter.LengthFilter(40)});
textView.setAdapter(adapter);
のXml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".myactivity">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textfield"
android:hint="Search..."/>
<Button
android:id="@+id/btn"
android:onClick="buttonClickHandler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Do something"
android:layout_toRightOf="@+id/textfield"/>
</RelativeLayout>
それを考え出した、あなたのxmlを投稿しすぎ –
@VivekMishraはにこれを追加しました質問 – Greg432
これはあなたの犯人の 'new InputFilter.AllCaps()'だと思います。私が理解していることは、このフィルタでは小文字を入力できないということです。あなたのtextviewに帽子の文字を入力してみてください –