0

I'm trying to get views from another layout modified these and then add them to the current layout. This is what i'm doing.

myLayout looks as follows:

<LinearLayout>
  <RelativeLayout>
    <TextView>

And my code:

LinearLayout layout = (LinearLayout) findViewById(R.id.linear);
ViewGroup info = (ViewGroup) getLayoutInflater().inflate(R.layout.myLayout, layout,false); 
RelativeLayout relative = (RelativeLayout) info.getChildAt(1);
ViewGroup vg = (ViewGroup) hiddenInfo.getChildAt(1);
TextField tv = vg.getChildAt(1);
...modify tv...
layout.addView(relative);
layout.addView(tv);

Though my program always crashes as layout.addView, what am i doing wrong?

4

0 回答 0