利用ViewPager+Fragment+slidingmenu側(cè)滑組件實現(xiàn)的小demo
19
20
public class ActivityFragment extends Fragment{
private View view;//緩存頁面
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if(view==null){
view=inflater.inflate(R.layout.activity_fragment,container, false);
}
ViewGroup parent = (ViewGroup) view.getParent();
if(parent!=null){
parent.removeView(view);//先移除
}
return view;
}
}
評論