1
I created a Fragment and I’m trying to call it when I click on a button, but it gives an error and it appears in the console
com.ample.Gustavo.easypasse.Reloade@30d409a0 must implement Onfragmentinteractionlistener
And point to that line of code:
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
How do I correct that?
And how should I implement? kkkk
– GustavoSevero
If you who created Fragment don’t know, how can I know if I don’t know his code?
– ramaral
First time working with Fragment kkkk I don’t know how to implement.
– GustavoSevero
It was you who wrote the code of this Fragment?
– ramaral
In fact I only created and assembled the screens of this Ragment, the Android Studio who assembled her Activity.
– GustavoSevero
Ok. If you do not need to communicate with Activity delete the method
onAttach()
, otherwise see the examples I added to the reply. Remember that I don’t have the ability to guess what you intend to do :)– ramaral
Before anything @Gustavosevero, recommend reading of this article, from Android Studio’s own doc, instead of using the DLSF technique (Drive Crazy and Go Doing)
– Grupo CDS Informática