Fragment使用出现空白页的解决方法

参考:http://blog.csdn.net/u014452224/article/details/45920315

所以在我们的fragment中写上这样的代码:

public class AndroidFragment extends Fragment {
    private View view;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if(view!=null){
            ViewGroup parent =(ViewGroup)view.getParent();
            parent.removeView(view);
        }
        view=inflater.inflate(R.layout.fragment_android,container,false);
        return view;
    }
}

就可以解决

你可能感兴趣的:(Android)