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);
大家在平时的开发中,用的是哪一种呢?