Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As Yashwanth Kumar correctly mentioned in the comments, the second parameter of the inflate-method should be the root view in which the new view will be inserted:</p> <pre><code>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); </code></pre> <p>If a root view is provided in the inflate-call, the LayoutInflator calls the <code>generateLayoutParams(ViewGroup.LayoutParams p)</code> method of this root view to get some LayoutParams (basically containing information about how big a view can/should be) which will be passed to the new view. </p> <p>Note that if you provide a root view, the inflated view will be automatically added to the root view via <code>root.addView(View child, LayoutParams params)</code>.</p> <p>You can also pass a third parameter to the inflate-method (<code>boolean attachToRoot</code>), if this value is <code>false</code>, the new view will not be added automatically to the root view, but the LayoutParams are still set with <code>setLayoutParams(params)</code>. You can use this if you wand to add you view manually to the root view (e.g. at a specific position/index):</p> <pre><code>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); // the LayoutParams of view are set here ll.addView(view, 2); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload