I have some EditText and I need them all to be filled in if the user does not fill in and try to hit the button to continue the text boxes should show an error. but this button is in the action bar and I do not know where to apply the verification
I have some EditText and I need them all to be filled in if the user does not fill in and try to hit the button to continue the text boxes should show an error. but this button is in the action bar and I do not know where to apply the verification
Speak Carlos,
You are inflating an xml with the items of your actionBar, correct?
Something like this:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(com.sample.R.menu.menu_main, menu);
}
So, you have to have a method that controls the clicks, for example:
public boolean OnOptionItemSelected(MenuItem item){
switch(item.getItemId()){
case R.id.enviarForm:
//verifica se o campo de texto está nulo
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Hugs.
But I would put a method, which checks whether the field is null or not, to be activated when the user clicks on the Button.
Take a look at this link. I hope it helps. When validating fields in a form in swing?