Android empty field validation in android or required field validation
we can solve this issue using setError().
———————————————
we can solve this issue using setError().
———————————————
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn =(Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn =(Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
EditText edittext =(EditText)findViewById(R.id.editText1);
if(edittext.getText().length()==0){
edittext.setError(“please enter the value”);
}
}
});
}
public void onClick(View v) {
EditText edittext =(EditText)findViewById(R.id.editText1);
if(edittext.getText().length()==0){
edittext.setError(“please enter the value”);
}
}
});
}
No comments:
Post a Comment