首页 > 代码库 > EditText点滴

EditText点滴

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);
    }
   }
  });

EditText点滴