LayoutInflater的作用类似于 findViewById(),不同点是LayoutInflater是用来找layout文件夹下的xml布局文件,并且实例化!而 findViewById()是找具体某一个xml下的具体 widget控件(如:Button,TextView等)
LayoutInflater factory=LayoutInflater.from(MainActivity.this);
//表示用一个xml来填充我们的View
View myView=factory.inflate(R.layout.login, null);
本文详细介绍了Android中LayoutInflater的作用及其与findViewById的区别。LayoutInflater主要用于加载XML布局文件并实例化视图。
2368

被折叠的 条评论
为什么被折叠?



