1、验证:
btnLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!username.getText().toString().equals("liyuhao")) {
username.setError("用户名错误",getResources().getDrawable(R.drawable.jewelry1));
}
}
});
btnLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!username.getText().toString().equals("liyuhao")) {
Drawable drawable = getResources().getDrawable(R.drawable.jewelry1);
drawable.setBounds(0, 0, 40, 40); //必须设置,否则不显示
username.setError("用户名错误",drawable);
}
}
});
原文:http://my.oschina.net/u/1389206/blog/335541