国家在Android电子
问题描述:
不是空的EditText我用这个selector
我EditText
:国家在Android电子
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/mostatil" /><!-- user tap on edit text -->
<item android:state_focused="false" android:drawable="@drawable/mostatil50" /><!-- user didn't tap or tap another edit text -->
<!-- state for not empty edit text -->
</selector>
是否有EditText
显示EditText
任何状态不为空(用户写了一些东西)?
答
/Just use the below code Snippet/
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/mostatil50" android:state_pressed="true" />
<item android:drawable="@drawable/mostatil" android:state_focused="true" />
<item android:drawable="@drawable/mostatil" />
</selector>
答
你可以检查的EditText是使用下面的代码空:
EditText edittext = (EditText)findViewById(R.id.edittext);
edittext = edittext.getText().toString();
if (edittext.matches("")) {
//do something here
}
else {
//do something else
}
感谢,但它并没有通过代码工作 – Fanous