0

我想构建一个Tab包含 aImageView和 a的视图,TextView并且我编写了一个名为Tabextends的类LinearLayout

eclipse 只是让我覆盖它的构造函数,我不知道它是如何工作的。

以及我对代码的困惑。

public Tab(Context context, AttributeSet attrs) {
    super(context, attrs);

    //-----is necessary?

    //removeAllViews();

    this.context = context;
    this.layoutInflater = (LayoutInflater) this.context.getSystemService(Service.LAYOUT_INFLATER_SERVICE);

    //-----what's different?

    //View v = this.layoutInflater.inflate(R.layout.tab, this, true);
    View v = this.layoutInflater.inflate(R.layout.tab, null);


    //-----which one is right?

    //this.iv = new ImageView(context, attrs);
    //this.tv = new TextView(context, attrs);

    //this.iv = (ImageView)v.findViewById(R.id.tab_icon);
    //this.tv = (TextView)v.findViewById(R.id.tab_text);

    //-----is necessary?

    //addView(this.iv);
    //addView(this.tv);
}
4

0 回答 0