0
我在android系統實施片段,我要面對的問題:片段的Android刷新
public Fragment getItem(int num) {
switch (num)
{
case 0:
NewFragment newFragment = new NewFragment();
//newFragment.refresh();
return newFragment;
case 1:
HotFragment hotFragment = new HotFragment();
//hotFragment.refresh();
return hotFragment;
default: return new ContentFragment();
}
}
當我點擊選項卡主鍵,它叫「onCreateView」和「onViewCreated」只有一次。但有了我的目的,我可以每次調用新的NewFragment()時調用回函數來處理?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_new, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//some config
}
我曾嘗試onDetach(),onAttach()的onResume(),但它不是我的目的,工作
你想做什麼?改述你的問題 – Pooya