How to check the value of various Switchs in Android Studio

Asked

Viewed 25 times

0

Hello, I’m creating a Checklist app, but Checklist has over 30 items and I’m using "Switch". When the user fills everything she will send to a database where someone else will see the items that are "checked", but wanted to know a way to check all Switchs without having to check one by one for example:

"Long Date" is the month the check list was made

item = findViewById(R.id.checklist_item1);
FirebaseDatabase.getInstance().getReference("CheckList").child(extensoData.toString()).setValue(item.isChecked()).addOnCompleteListener(new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {
                        Toast.makeText(CheckListsem.this, "CheckList feita.", Toast.LENGTH_SHORT).show();
                    }
                });
  • How’s the hierarchy of your database?

  • ```Checklistid -> Vehicle-> Date -> item1 = "true"```` Obs; "Vehicle" would be the name of the Checklist the person is making, for example; it has 2 types of Checklist "Tractor" and "Kombi".

  • I couldn’t see very well yet, but couldn’t you save all checked items instead of a Boolean for each, but save as an array of strings? So you recover at once all that had been checked.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.