A button in my app should only get the text in 8 text fields and send it to a table IF all fields are filled in

前端 未结 3 394
半阙折子戏
半阙折子戏 2021-01-29 15:21

A button in my app gets all the text you enter in 8 text fields and sends it to a table. I need code so that you need to fill in ALL fields before you can send the info. How do

3条回答
  •  心在旅途
    2021-01-29 16:00

    You use the AND boolean operator; &&

    if(!textfield1.getText().equals("") && !textfield2.getText().equals("") && !textfield3.getText().equals("") && so on){
    //fill table in
    }
    

    In case you didn't know, ! means NOT, so we're saying 'if text field 1 is not empty and textfield 2 is not empty and ...'

提交回复
热议问题