[Q] Inflate view inside inflated view

Search This thread

fjnieto15

New member
Nov 24, 2012
4
0
Hi, I need to inflate a view with an xml, but inside that view to inflate other view with a different xml. I have tried a lot of things but I'm still not able to achieve what I want :S need some help please...

Here is the code I'm using:
Code:
public void setPract(Practica[] _pract, int _code){

    TableLayout table = (TableLayout)findViewById(R.id.TablePracts);
    TableRow row;

    //more stuff...

    for (int k = 0; k < _practLength; ++k) { //_practLength gives the number of subject_practcard.xml I want and is working OK

        LayoutInflater inflater = LayoutInflater.from(VistaAsignatura.this);
        row = (TableRow) inflater.inflate(R.layout.subject_practcard, null, false);

        //xml stuff working OK...

        table.addView(row);


        TableLayout tableGroup = (TableLayout)table.findViewById(R.id.TableGroups);


        for (int j = 0; j < _groupLength; ++j) { //_practLength gives the number of subject_texts.xml I want and is working OK


            TableRow rowGroup = (TableRow) inflater.inflate(R.layout.subject_texts, null, false);

            //more stuff...

            //xml stuff working OK...

            tableGroup.addView(rowGroup);

        }

    }

}

So, the problem is that if, for example, _practLength is 3 and _ groupLength is 2 all the three timesm I'm getting al the rowGroup done in the first subject_peccard.xml and not 2 in the first one, 2 in the second one and finally another 2 in the third one.

I'm adding a little scheme so its easier to understand what I'm triying to do:

http:/ /i.stack.imgu r.com/Z aiJY.png

Hope you can help me as I need to make it work :S

Thanks in advance