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);
}
}
});
时间: 2024-10-19 11:21:31