tags:

views:

24

answers:

1

Hi, I am having a TableLayout for which I added rows dynamically.In each of the row there are 2 elements of which one is TextView other is Button.When I click the button that is present in a row,that row should be deleted.How can this be done in Android ? How to find rowid and how to delete a row dynamically. can anyone help me in sorting out this issue.

Thanks in Advance,

A: 

Try this kind of approach:

    TableRow tableRow;
    TextView tv;
    Button button;
    //...
    tableRow.addView(tv)
    tableRow.addView(button);


    //somewhere where you want to delete
    ViewGroup parent=button.getParent();
    if(parent instanceof TableRow)
        //do deleting task
barmaley
Currrently my design is changed I am dynamically adding Textview and checkbox as a row to table. Outside table I have a button. When I click the button and if check box is selected in any row, then that particular row should be deleted.How to know which checkbox is checked ?As I need to know whether it is ViewParent or ViewGroup
Android_programmer_camera
You need to know TableLayout handle and using it's handle you can enumerate all available child views, so you'd know checkboxes. As you'd know checkbox you can have it's TableRow
barmaley