静态创建fragment

导入的包是v4包要向下兼容3.0开始后才有新的fragment
在oncreatView的方法返回对应的view

public class myfragment extends Fragment {
    
    @Override
    public void onDetach() {
        // TODO Auto-generated method stub
        super.onDetach();
    }
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
    }
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.dd, container);
        System.out.println("haha");
        
        return inflate;
    }

//在xml中配置fragment



   


你可能感兴趣的:(静态创建fragment)