activity refresh fragment

1. Create an interface.

public interface Listener {
    void listener(int position);
}

2. Implement the interface in the activity

Listener  linstenr ;
public void setLinstenr ( Listener linstenr) {
     this . linstenr = linstenr ;
}

3. Set the listener for the activity in onAtth() of the fragment.

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    MainActivity mainActivity = (MainActivity) activity;
    mainActivity.setLinstenr(this);
}

@Override
public void listener(int position) {
    ToastUtil.showShort(getActivity(), position + "");
}
4. Called in the activity.

if ( linstenr != null ){
     linstenr .listener( position ) ;
}

Guess you like

Origin blog.csdn.net/qq_34475640/article/details/70249781