天天看點

Android 學習之路 獲得inflate的三種方式

1.

view = view.inflate(getApplicationContext(),R.layout.layout, null);

2.

LayoutInflater.from(getApplicationContext()).inflate(R.layout.layout,null);
           

3.

LayoutInflater inflater= (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.layout, null);
           

三種方式都可以獲得打氣筒 inflate 

第三種用的比較多