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对象,但在这个例子中,作者不会在任何地方存储结果。在通货膨胀之后,从此类创建的新视图如何创建?我想过把它分配给“这个”,但这似乎是非常错误的。
感谢您的任何澄清。
,非常感谢,这是非常合情合理的。 – 2010-04-26 01:07:56