0

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();
}
4

1 回答 1

0

Try this from the fragment: ((MainActivity)getActivity()).setNumPlats(20)

于 2015-03-13T16:35:16.273 回答