在您的Fragment中创建一个自定义界面:
public interface onFragmentInteractionListener { public void onFragmentSetStudents(ArrayList<Student>); }在您的活动中实现此接口:
public class YourActivity extends Activity implements YourFragment.onFragmentInteractionListener { private ArrayList<Student> allStudents;}现在,您必须重写声明的方法(在中
Activity):
@Overridepublic void onFragmentSetStudents(ArrayList<Student> students) { allStudents = students;}然后,您只需要使用Fragment中的Listener来启动此方法:
onFragmetInteractionListener listener = (OnFragmentInteractionListener) activity;listener.onFragmentStudents(allStudents)



