获取inflater的多种方法

来源:互联网 发布:绘制平面图软件 编辑:程序博客网 时间:2024/05/14 23:38

inflater,俗称打气筒,作用是可以把一个布局转换为一个view对象。是Adapter中必备的工具。

//第一种方法View.inflate(getApplicationContext(),R.layout.item,null);//第二种方法context.getLayoutInflater().inflate(R.layout.item,null);//第三种方法LayoutInflater.from(getApplicationContext()).inflate(R.layout.item,null);//第四种方法LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);view = inflater.inflate(R.layout.item,null);

大家在平时的开发中,用的是哪一种呢?

0 0
原创粉丝点击