Get a child view of TableRow in a TableLayout

Get a child view of TableRow

To get child View of a TableRow, you can use following method,

tablerow.getChildAt(columnno);
//here columnno is 0 based index

eg:

At times we store string data in tag of TableRow View using setTag(“tagdata”) method, We can get that stored data using following code

If View is placed in 5th column

for (int i = tl.getChildCount(); --i >= 1;) { 
//here --i>==1 is used to exclude table header
     TableRow tr=(TableRow)tlServiceManual.getChildAt(i);
     View chkView=(View)tr.getChildAt(4);
    // here column is 4, since 0 based index
     if(chkView.getTag()!=null{
         //do something
     }
}

Hope it helps somebody..

(Y)

You may be also interested

 

Leave a Reply

Your email address will not be published. Required fields are marked *