This is the setter method in MainActivity class
public void setNumPlats(int numero){
this.numPlats = numero;
}
I'm trying to acces to this method from fragment class, but i dont know how i need to do this.
In the fragment class i'm trying to do this
I'm trying it, and it doesnt makes error when i put it into onAttach, but when i execute the app it crashes. @Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
((MainActivity)getActivity()).setNumPlats(adapter.getNumPlats());
@Override
public void onDetach() {
super.onDetach();
}