您的位置:首页 > 移动开发 > Android开发

对布局对象及其子控件进行操作

2017-01-18 20:18 253 查看
protected LinearLayout mTabsHolder=null;
View viewLikeBtn=null;

mTabsHolder=(LinearLayout)findViewById(R.id.tabs_holder);

int count=mTabsHolder.getChildCount();//得到布局控件中子控件的数量
mTabsHolder.removeViews(0,count);//从位置0开始移除count个子控件

mTabsHolder.addView(viewLikeBtn);//向布局中添加视图控件

TextView homeBtn=(TextView)mTabsHolder.getChildAt(0);//获取位置0 的控件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android