我有带有 2 个标签的 FragmentTabHost。每个片段(选项卡)都需要从互联网加载数据并显示它。
如果我正在加载数据 onCreate 并填充它然后切换到另一个选项卡并返回我有空视图。
TextView emailView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View convertView = inflater.inflate(R.layout.contactdetails_pro, container, false);
emailView = (TextView) convertView.findViewById(R.id.contactdetails_info_email);
return convertView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String id = getArguments().getString("id");
MyTask pdthread = new MyTask(this.getActivity(), id, new AsyncTaskCompleteListener() {
@Override
public void onComplete(Detail detail) {
emailView.setText(detail.getEmail());
}
});
pdthread.execute();
}