multi-level addview
<p>I'm trying to create multi-level addview. 
I'm mean that I want to inflate other view in an inflated view.
here is the code : </p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pres_racikan);
    addListenerOnButton();
    AddResep(view);
}

public void addListenerOnButton() { 
    btnSave = (Button)findViewById(R.id.btnSave);
    btnSave.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "You Click save_button()", Toast.LENGTH_LONG);
        }
    });
    btnCancel = (Button)findViewById(R.id.btnCancel);
    btnCancel.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });
    ivAddR = (ImageView)findViewById(R.id.ivAddResep);
    ivAddR.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            AddResep(v);
        }
    });

}

protected void AddResep(View v) {
    tblR = (TableLayout)findViewById(R.id.tblRacikanDetail);
    trR = new TableRow(this);
    v = LayoutInflater.from(getApplicationContext()).inflate(R.layout.pres_racikan_detail, trR, isChild());
    ivHapusR = (ImageView)v.findViewById(R.id.ivHapusResep);
    ivHapusR.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            View vr = (View)v.getParent();
            ViewGroup vg = ((ViewGroup)vr.getParent());
            vg.removeAllViews();
            vg.invalidate();
        }
    });
    tblItem = (TableLayout)findViewById(R.id.tblRacikanDetailItem);
    ivAddItem = (ImageView)v.findViewById(R.id.ivAddResepItem);
    ivAddItem.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // I would like to inflate another view to add to tblItem, just like I added to tblR.

        }
    });

    tblR.addView(v);
}

}
</code></pre>

<p>Here is my pres_racikan_detail .xml :</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" &gt;

&lt;TableRow
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="5dp" &gt;

    &lt;ImageView
        android:id="@+id/ivAddResepItem"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_marginRight="10dp"
        android:clickable="true"
        android:src="@drawable/btn_add_selector" /&gt;

    &lt;TextView
        style="@style/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:paddingBottom="5dp"
        android:paddingTop="5dp"
        android:text="Item"
        android:textSize="24dp" /&gt;

    &lt;TextView
        style="@style/label"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:paddingBottom="5dp"
        android:paddingTop="5dp"
        android:text="Qty"
        android:textSize="24dp" /&gt;

    &lt;ImageView
        android:id="@+id/ivHapusResep"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:clickable="true"
        android:src="@drawable/btn_delete_selector" /&gt;
&lt;/TableRow&gt;

&lt;View
    android:layout_width="match_parent"
    android:layout_height="0.5dp"
    android:background="#CAD8E8" /&gt;

&lt;TableLayout
    android:id="@+id/tblRacikanDetailItem"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" &gt;
&lt;/TableLayout&gt;

&lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_marginTop="5dp"
    android:orientation="vertical"
    android:paddingLeft="10dp"
    android:paddingRight="10dp" &gt;

    &lt;TextView
        style="@style/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:paddingBottom="5dp"
        android:text="Instruction" /&gt;

    &lt;EditText
        android:id="@+id/txtInstruction"
        style="@style/input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:ems="10"
        android:hint="@string/free_text" /&gt;
&lt;/LinearLayout&gt;

&lt;LinearLayout
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:orientation="vertical"
    android:paddingLeft="10dp"
    android:paddingRight="10dp" &gt;

    &lt;TextView
        style="@style/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:paddingBottom="5dp"
        android:text="Signa" /&gt;

    &lt;EditText
        android:id="@+id/txtSigna"
        style="@style/input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="@string/free_text" /&gt;
&lt;/LinearLayout&gt;


&lt;View
    android:layout_width="match_parent"
    android:layout_height="0.5dp"
    android:background="#CAD8E8" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>When I click <code>ivAddItem</code>,  I would like to insert view to <code>tblItem</code> which I will inflate from this layout. </p>

<p>pres_racikan_detail_item.xml :</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;TableRow xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/TableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp" &gt;

&lt;ImageView
    android:id="@+id/ivHapusResepItem"
    android:layout_width="35dp"
    android:layout_height="35dp"
    android:layout_marginRight="10dp"
    android:clickable="true"
    android:src="@drawable/ic_delete_selector" /&gt;

&lt;TextView
    style="@style/label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="10dp"
    android:layout_weight="1"
    android:paddingBottom="5dp"
    android:paddingTop="5dp"
    android:text="Obat 1 untuk Racikan" /&gt;

&lt;EditText
    android:id="@+id/txtQtyList"
    style="@style/input"
    android:layout_width="80dp"
    android:layout_height="wrap_content"
    android:layout_marginRight="10dp"
    android:inputType="numberDecimal" &gt;

    &lt;requestFocus /&gt;
&lt;/EditText&gt;

&lt;Button
    android:id="@+id/btnSatuan1"
    style="@style/blue_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingBottom="10dp"
    android:paddingLeft="15dp"
    android:paddingRight="15dp"
    android:paddingTop="5dp"
    android:text="mg"
    android:textSize="20dp" /&gt;

&lt;/TableRow&gt;
</code></pre>

<p>Please tell me how could I do that.
Please tell me in detail.</p>

<p>Thanks in advance.</p>
