天天看點

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。

本文轉自 pangfc 51CTO部落格,原文連結:http://blog.51cto.com/983836259/1399139,如需轉載請自行聯系原作者

繼續閱讀