Is it possible to make an onClickListener app-global?
I basically have several fragments that will use the same numpad buttons for input and instead of registering and filtering click events for each button in each fragment I wanted to ask if it was possible to share an onClickListener throughout the entire app.
This is the setting:
public class LoginFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle states) {
this.context = getActivity();
// TODO: Register onClickListener...somehow
context.registerReceiver(receiver, filter); //For the intent listening
view = inflater.inflate(R.layout.layout_login_screen, container, false);
buildUI(null);
return view;
}
(and two different fragments simmilar to this one)
and then the idea was:
public class NumPadListener implements OnClickListener {
@Override
public void onClick(View v) {
System.out.println("Yup...I'm listening?");
// TODO: Do funny intent stuff here
}
}
Is this even possible? And if yes, how? :) If it isn't, do you have any recommendations on how to implement this in the best way? Thanks