我在我的应用程序3个sherlockListFragments。 每个片段都有一些editTexts最后片段有一个当它压在第一和第二片段的所有数据应该被访问和保存按钮。 我用束片段之间发送数据。 用简单的以下示例中,这是我的第一片段的代码:
public class PersonalDataFragment extends SherlockListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragmet_personal_data, container, false);
return v;
}
@Override
public void onCreate(Bundle savedInstanceState) {
PersonalDataFragment fragment = new PersonalDataFragment();
Bundle bundle = new Bundle();
bundle.putString("y", "koko"); //any string to be sent
fragment.setArguments(bundle);
super.onCreate(savedInstanceState);
}
},这是接收文本片段的代码:
public class WorkExpRefFragment extends SherlockListFragment {
String myInt;
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_workexp_ref, container, false);
final EditText t = (EditText) view.findViewById(R.id.editText5);
final Button generate = (Button)view.findViewById(R.id.button2);
generate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
t.setText(myInt + "sadfigha");
}
});
return view;
}
@Override
public void onCreate(Bundle savedInstanceState) {
Bundle bundle = this.getArguments();
if(getArguments()!=null) {
myInt = getArguments().getString("y");
}
super.onCreate(savedInstanceState);
}
}
现在我有一个空的第三个片段,我应该怎么办? 提前致谢