How to handle events and validation between child and parent fragment in android

109 Views Asked by At

I used the navigation component to navigate between fragments. In one of these fragments, I have a fragment that contains a view pager. In this view pager, I have 3 different fragments that handles with 2 buttons for go next page and back to the previous page in parent fragment. Now if I want to at first validate for example editText in fragmentOne in viewPager then if all editText contains valid data enable next button in parent fragment what shall I do? (for 3 child fragment I had to do these validations for enabling next button in the parent fragment) . and for sending data from these three children fragments to parent fragment what shall I do?

I think have to use 6 interfaces (3 of them for check validation (3 because I have 3 child fragment into view pager and for each child fragment use one interface) to enable next button and 3 of them for sending data from children fragments to parent fragment)

I look for a clean way to implement this section. And I used MVVM architecture.

0

There are 0 best solutions below