我有一個編輯文本,我驗證。如果輸入的數據沒有響應格式,我將背景設置爲紅色,當它設置爲淺灰色時,矩形會消失。 我想知道當輸入的數據格式正確時,是否可以將它的屬性重置爲其原始值。 這是我在做什麼現在如何重置edittext的樣式?
EditText name = (EditText) findViewById(R.id.Name);
if (name.getText().length() < 1)
{
error = true;
unit.setBackgroundColor(Color.RED);
}
else
{
//instead of this line reset edittext properties
unit.setBackgroundColor(Color.LTGRAY);
}
你是什麼意思重置? – MDMalik
你的意思是什麼「矩形消失」?所以當它設置爲RED時,一切都很好,但是將其設置爲LTGRAY時,框的邊框會消失? – randomizer
是邊框消失 – Liviu