Read More
Read now

How to use interface with handler to transfer data between activity and fragment

Save

Interfaces are more flexible than base classes because you can define a single implementation that can implement multiple interfacesInterfaces are better in situations in which you do not have to inherit implementation from a base class.Interfaces are useful when you cannot use class inheritance.

Make an interface like given below where we define multiple methods with different parameters.

Any fragment that should pass data back to its containing activity should declare an interface to handle and pass the data.Then make sure your containing activity implements those interfaces. For example:

Here, ((Your Fragment which implements the interface )).getFileCode(Parameters which you want to be transferred) replace fragment with the container and commit. In your fragment where getFileCode you will get your data in your replace fragment.

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

Deniel Kerr

Owner and Founder. Opencart

Talk to Sales
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home