有xmlA,xmlB;MainActivity。Main中有xmlA的点击方法,要在用户点击xmlA时改变xmlB的内容,应该如何获取xmlB?
3条回答
- legendCoder 2017-08-20 06:03关注
LayoutInflater layoutInflater = LayoutInflater.from(this);
View layout = layoutInflater.inflate(R.layout.layout, null);
通过这种方式加载view和setContentView不同。setContentView是直接加载到ui界面上,layoutInflater.inflate只获取你想要的view。
解决 无用评论 打赏 举报