2010-04-26 32 views
1

雖然研究如何創造的Android定製的複合意見,我也碰到過這種模式有很多(例如來自Orange11 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); 
} 

}

我大多理解這是如何工作的,除了調用inflate()的部分。該文檔說這個方法返回一個View對象,但在這個例子中,作者不會在任何地方存儲結果。在通貨膨脹之後,從此類創建的新視圖如何創建?我想過把它分配給「這個」,但這似乎是非常錯誤的。

感謝您的任何澄清。

回答