aと aTab
を含む Viewを構築したいと思います。そしてextendsという名前のクラスを書きます。ImageView
TextView
Tab
LinearLayout
日食はコンストラクターをオーバーライドするだけで、どのように機能するかわかりません。
そして私のコードの混乱。
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);
}