Delete button in TableRow
<p>I have an <strong>Edit</strong> button in my header. And I populating my <strong>TableLayout</strong> in a loop. In The loop I am inflating a <strong>Delete</strong> button.<br>
Following is the code I have used :  </p>

<p><strong>MainActivity</strong> :  </p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cookbooklist);

    btnHeaderEdit = (Button)findViewById(R.id.btnEdit);
    btnHeaderEdit.setVisibility(View.VISIBLE);
    delete_button = (View)findViewById(R.id.btnDelete);
    listTable = (TableLayout)findViewById(R.id.cookbookListTable);
    btnHeaderEdit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
        delete_button.getTag();
        delete_button.setVisibility(View.VISIBLE);  
        }
    });

    for(int i=0;i&lt;=10;i++)
    {
        // Row to display news title
        final TableRow newsRow = new TableRow(this);
        newsRow.setMinimumHeight(200);
        newsRow.setClickable(true);
        newsRow.setTag(i);
        newsRow.setBackgroundColor(Color.WHITE);

        // Some other views

        //create inflater
        LayoutInflater inflater = getLayoutInflater();   
         delete_button = inflater.inflate(R.layout.deletebutton,
                    (ViewGroup) newsRow, false);
         delete_button.setTag(i);
         delete_button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                listTable.removeView(newsRow);
            }
        });

        //Add views in table

        newsRow.addView(delete_button);
        listTable.addView(newsRow);

    }
}  
</code></pre>

<p><strong>delebutton.xml</strong> :  </p>

<pre><code>&lt;Button 
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/btnDelete" 
android:layout_width="100dip" 
android:visibility="invisible"
android:layout_height="40dip" 
android:padding="10sp" 
android:text="Delete"&gt;  
&lt;/Button&gt;  
</code></pre>

<p><strong>Question</strong> :  </p>

<p>The problem I am facing is that when I click the <strong>Edit</strong> button in header, <strong>Delete</strong> button appears only in the last row. When I setVisibility of <strong>Delete</strong> button to Visible in layout, it appears in all rows. But I want it to be invisible in the start. And on clicking the <strong>Edit</strong> button it should appear in all rows. I Am wondering how to achieve that.<br>
Can someone assist me? Let me know if more code is needed.</p>

<p>Thanks 
The problem I am facing is that when</p>
