dimanche 8 mai 2016

Have Button Check the State of CheckBoxes

I'm having issues trying to get my button to check and ensure that my checkboxes have been checked before opening the next activity.

Planning to use else/if to check the checkboxes and if they are not checked I can throw an alert to the user letting them know they are required. If they are check it'll continue on an open the activity.

public class ConnectAPRS extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_connect_aprs);

        final EditText  callsign = (EditText)   findViewById(R.id.callsign);
        final EditText  passcode = (EditText)   findViewById(R.id.passcode);
        final CheckBox  licensed = (CheckBox)   findViewById(R.id.licensed);
        final CheckBox  authorized = (CheckBox) findViewById(R.id.authorized);

        final Button    bConnect = (Button)     findViewById(R.id.bConnect);

        bConnect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(ConnectAPRS.this, Contacts.class));
            }
        });
    }
}




Aucun commentaire:

Enregistrer un commentaire