keeping references to inflated custom views

Posted by darren on Stack Overflow See other posts from Stack Overflow or by darren
Published on 2010-04-26T00:26:35Z Indexed on 2010/04/26 0:33 UTC
Read the original article Hit count: 593

Filed under:
|

Hi

While researching how to create custom compound views in Android, I have come across this pattern a lot (example comes from the Jteam blog) :

public class FirstTab extends LinearLayout {
private ImageView imageView;
private TextView textView;
private TextView anotherTextView;

public FirstTab(Context context, AttributeSet attributeSet) {
    super(context, attributeSet);

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.firstTab, this);
}

}

I mostly understand how this is working, except for the part where inflate() is called. The documentation says that this method returns a View object, but in this example the author does not store the result anywhere. After inflation, how is the new View created fromt eh XML associated with this class? I thought about assigning it to "this", but that seems very wrong.

thanks for any clarification.

© Stack Overflow or respective owner

Related posts about android

Related posts about views