As Yashwanth Kumar correctly mentioned in the comments, the second parameter of the inflate method should be the root view into which the new view will be inserted:
LinearLayout ll = (LinearLayout) findViewById(R.id.llContainer);
View view;
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.question_free_text, ll);
, LayoutInflator generateLayoutParams(ViewGroup.LayoutParams p) , LayoutParams ( , / ), .
, , root.addView(View child, LayoutParams params).
inflate (boolean attachToRoot), false, , LayoutParams setLayoutParams(params). , (, /):
LinearLayout ll = (LinearLayout) findViewById(R.id.llContainer);
View view;
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.question_free_text, ll, false);
ll.addView(view, 2);
source
share