Activity里面嵌入Fragment一点小代码

  在Activity里面填充界面,可以直接把界面内容写在Activity里面,这不是最好的,有的时候为了模块化会选择下面的方式
可以再在Activity里面填充一个Fragment(就是把fragment填充到Activity里面)!!

public class ConversionCenterActivity extends BaseFragmentActivity implements Constant{

    

    private ConversionCenterFragment mConversionCenterFragment;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_conversion_center);

        mConversionCenterFragment=new ConversionCenterFragment();

        getSupportFragmentManager().beginTransaction().replace(R.id.center_layout, mConversionCenterFragment).commit();

    }



}

 

你可能感兴趣的:(Activity)