2012-04-18 8 views
5

Android 1.6(4)および2.3.3(10)でテスト済みです。Android EditText inputType = "none"は機能しません。 "textMultiLine"になります

私はそれがないすべてがでXMLをロードしている、このことを実証するための最小限のテストアプリケーションを作った:

setContentView(R.layout.main); 

とxmlは次のとおりです。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" /> 

<EditText 
    android:id="@+id/editText1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:inputType="none" 
    android:ems="10" > 

</EditText> 

問題:

inputType="none"を実行時の実際の入力タイプに設定する場合textMultiLine(0x00020001)となりました。私はデバッガでそれをチェックしました。

一方、inputType="text"を使用すると、期待どおりに動作します。

これはAndroidのバグですか?

答えて

12

私は同じ問題を抱えていた:動作しませんでしたXMLを介して入力タイプを定義します。

@Override 
public void onActivityCreated(@Nullable Bundle savedInstanceState) 
    { 
    ... 
    editText1= (EditText) super.getActivity().findViewById(R.id.editText1); 
    editText1.setInputType(InputType.TYPE_NULL); // none... 
    ... 
    } 

私の作品:

はその後、それを修正するために、私はプログラム的に入力タイプを設定します。

+4

値をバインドします –

1

をsuggests-。これは非推奨ですが、inputTypeがそうでない場合に機能します。

1

使用すると、この

textView.setKeyListener(null); 
1

InputType = "none"の設定xmlは機能しませんが、データバインディングを使用している場合は、バインディング構文を使用して入力タイプを設定できます。

が..

<data> <import type="android.text.InputType" /> </data>

タイプをインポートし `setInputType(InputType.TYPE_NULL)を`使用する方

<EditText android:id="@+id/edit_text" android:inputType="@{InputType.TYPE_NULL}" />

関連する問題