大叔第13天 @LayoutInflater的一段代码

radio.setOnCheckedChangeListener(new OnCheckedChangeListener() {

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int i=0;
if(btn0.getId()==checkedId){
i=0;
}else if(btn1.getId()==checkedId){
i=1;
}else if(btn2.getId()==checkedId){
i=2;
}else{}
switch(i){
case 0:
box.removeAllViews();
box.addView(View.inflate(MainActivity.this, R.layout.product_taobao,null)); //添加子页面
break;
case 1:
Log.v("xxx","yyy");
box.removeAllViews();
box.addView(View.inflate(MainActivity.this, R.layout.product_product, null)); //添加子页面
break;
case 2:
box.removeAllViews();
box.addView(View.inflate(MainActivity.this, R.layout.product_service, null)); //添加子页面
break;
}

}
});

 

posted @ 2013-03-18 10:35  linsen@java  阅读(142)  评论(0编辑  收藏  举报