sunwy 发表于 2013-7-4 22:53:23

LayoutInflater与findViewById的用法

LayoutInflater与findViewById的用法有很多可比较之处。
如:他们都可以通过id返回View。
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.custom_dialog,null);
Button button = (Button) findViewById(R.id.button);
不同之处是:LayoutInflater是用来实例化整个布局文件,而findViewById()是实例化布局文中中的View。


http://bbs.sunwy.org/xwb/images/bgimg/icon_logo.png 该贴已经同步到 sunwy的微博

muzi 发表于 2013-7-4 23:10:02

我们菜鸟是看不懂什么意思,占个沙发坐坐。:P
页: [1]
查看完整版本: LayoutInflater与findViewById的用法