问题
My code is :
<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"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="53dp"
android:layout_marginTop="34dp"
android:inputType="textNoSuggestions|text"/>
</RelativeLayout>
JAVA Code I Use.
editText = (EditText) findViewById(R.id.editText);
editText.setInputType(InputType.TYPE_MASK_CLASS|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
I use android:inputType="textNoSuggestions|text" in EditText its disabled predictive text for all devices but in Samsung Tab 2 it's not working. I also apply through android code but seems its open give any other suggestions for disabled this predictive text box in Samsung Tab 2.
Other device preview it's not showing predictive text box.
Samsung Tab 2 preview it's showing predictive text box.
回答1:
i have also same problem is once upon time and i am find solution change edittext input type as textVisiblePassword
like mention below xml layout
<EditText
android:id="@+id/password"
android:layout_width="320dp"
android:layout_height="50dp"
android:textColor="@android:color/black"
android:ems="10"
android:inputType="textVisiblePassword"
android:padding="10dp"
android:layout_marginTop="1dp"
android:textSize="22dp" />
It's will works on samsung tab2 on following code
android:inputType="textVisiblePassword"
来源:https://stackoverflow.com/questions/17418937/android-how-to-disabled-predictive-text-programatically-in-samsung-tab-2