android 在布局中动态添加控件
            时间:2014-04-28 02:54:25  
            收藏:0  
            阅读:515
        
        
        第一步
- final LayoutInflater inflater = LayoutInflater.from(this);
 
第二步:获取需要被添加控件的布局
- final LinearLayout lin = (LinearLayout) findViewById(R.id.LinearLayout01);
 
第三步:获取需要添加的布局(控件)
- LinearLayout layout = (LinearLayout) inflater.inflate(
 - R.layout.listview, null).findViewById(R.id.layout);
 
第四步:添加到布局中
- lin.removeAllViews();
 -                 lin.addView(layout);  
    
 
            评论(0)