I have validation for editText
. If the editText
field is empty it should fail validation and stop the user moving on to another Activity
,
Try this:
bt.setOnClickListener(new OnClickListener() {
public void onClick(View arg0)
{
String str=et.getText().toString();
if(str.equalsIgnoreCase(""))
{
et.setHint("please enter username");//it gives user to hint
et.setError("please enter username");//it gives user to info message //use any one //
}
else
{
Intent in=new Intent(getApplicationContext(),second.class);
startActivity(in);
}
}
});