Q:

about android inflation parameter

    public class Inflation2 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super. onCreate ( savedInstanceState) ;
LinearLayout linear = new LinearLayout(this);
linear. set0rientation ( LinearLayout. VERTICAL) ;
linear. setBackgroundColor( Color. LTGRAY) ;
TextView text = new TextView(this);
text. setText( "TextView" ) ;
text. setGravity( Gravity. CENTER) ;
text. setTextColor( Color. RED) ;
linear. addView( text) ;
setContentView( linear) ;
}
}

LinearLayout linear = new LinearLayout(this); 
in this code, why do I have to use 'this' parameter

A:

it's the context of the current state of the application/object. It lets newly-created objects understand what has been going on. Typically you call it to get information regarding another part of your program (activity and package/application).
You can get the context by invoking getApplicationContext(), getContext(), getBaseContext() or this (when in a class that extends from Context, such as the Application, Activity, Service and IntentService classes).
this is a reference to your Activity when you do this LinearLayout linear = new LinearLayout(this) means it will create LinearLayout for you Inflation2 Activity

