I have a checkbox inside a fragment and i want to it respond on click of a button this button is inside my main activity
By : shhaugen
Date : March 29 2020, 07:55 AM
should help you out You can use interface to communicate back to MainActivity. Create a interface and implement it on MainActivity. Pass the implemented interface to fragment and store it in the fragment Then When your checkbox state change check that the stored interface is null or not if not null then call the implemented method of the interface, which is actually implemented in MainActivity. This way you can communicate back to MainActivity. In MainActivity store your checkbox state and do what you want to do in button press.