2014-09-20 22 views
2

這裏是我的XML的EditText與「文」的inputType沒有隱瞞錯誤彈出時,文本更改

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="@string/barcode" 
    android:id="@+id/barcode" 
    android:inputType="number" /> 
<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="@string/name" 
    android:id="@+id/name" 
    android:inputType="text" /> 

我設置錯誤這兩個領域:

((TextView) findViewById(R.id.barcode)).setError(getString(R.string.at_least_one_field)); 
((TextView) findViewById(R.id.name)).setError(getString(R.string.at_least_one_field)); 

當我運行應用程序並更改內容在barcode字段中出現錯誤彈出窗口。 而當我在name字段中更改內容時,彈出式窗口不會隱藏。只有當我點擊鍵盤上的完成按鈕時纔會隱藏。

爲什麼numbertext字段有不同的行爲?

+0

在'barcode'發現了一個解釋,或者它消失在你開始輸入後,你點擊後在第二個TextView中? – 2014-09-20 15:25:20

+0

@KubaSpatny當我開始輸入時它就消失了。 – Turako 2014-09-21 12:04:21

回答

2

我有同樣的問題,「文本」的inputType,並在這個崗位https://stackoverflow.com/a/23599214/3005955

textView.addTextChangedListener(new TextWatcher() { 
    public void afterTextChanged(Editable edt) { 
     if(playerName.getText().length() > 0) { 
      playerName.setError(null); 
     } 
    } 
}); 
+0

感謝您的解決方案。但一些如何修復,可能是針對SDK的bug修正版發佈。 – Turako 2014-11-06 04:40:10

相關問題