oblige user to fill edittext

1

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

    
asked by anonymous 25.07.2016 / 16:21

2 answers

1

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.

    
25.07.2016 / 17:06
0

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?

    
25.07.2016 / 16:56