Nullpointerexception With Fragment Interface Listener
I'm sorry, I'm sure that this will be simple but I just cannot see where I'm going wrong here. I've got a Fragment (a tool list) that can start a number of other fragments (tools)
Solution 1:
I can see you define 2 interface with the same name in each fragment.
publicinterfaceOnFragmentButtonClickedListener {
publicvoidonFragmentButtonClicked (int button, Fragment fragId);
}
But the activity can implement only one interface with this name (in this case, I believe your activity implement interface of first fragment) and maybe this cause error null pointer exception of second fragment.
//where is OnFragmentButtonClickedListener come from?publicclassMyActivityextendsFragmentActivityimplementsFirstFragmentOnFragmentButtonClickedListener
Try to write OnFragmentButtonClickedListener outside of 2 fragments ( maybe in another file)
Post a Comment for "Nullpointerexception With Fragment Interface Listener"