Android 动态更改布局

来源:互联网 发布:医疗器械研发 知乎 编辑:程序博客网 时间:2024/05/21 11:37


用四句话解释  

建立好新的布局->生成布局实例 ->删除旧布局->加入新的布局,程序如下:

 

 

     LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.layout02, null);

    RelativeLayout relativelayout = (RelativeLayout) findViewById(R.id.top);

    relativelayout.removeView(findViewById(R.id.layout01));

    relativelayout.addView(layout);

 参加  第二届 Google 暑期大学生博客分享大赛 - 2011 Android 成长篇