Reputation: 1695
Only thing that i want is to detect button click in fragments .
Upvotes: 0
Views: 1151
Reputation: 7479
There are many ways to interact between fragments and activities, and you can find them by searching here on SO, but the easiest way I've found so far and the one I love using the most is a 3rd party library, called EventBus.
You can simply post an event on button click, custom event which can carry all kinds of data, and then in your fragment, simply write a method that listens for that event and does whatever is necessary.
Upvotes: 1
Reputation: 2383
If your button is interacting with your fragment, it should not be separated.
However, you can do:
getActivity().findViewById(...)
inside your fragment
Upvotes: 1