ビューページャーを使用して CollectionActivity というアクティビティがあります。ビューページャーには独自のアダプター PagerAdapter があります。 CollectionPagerAdapter は PagerAdapter を拡張します。
重要な instantiateItem メソッド:
@Override
public Object instantiateItem(View collection, int position) {
        LinearLayout lay = null;
        if(position==0){
            lay = new Report(context);
            lay.setOrientation(LinearLayout.VERTICAL);
            ((ViewPager) collection).addView(lay);
        }
//else for the other positions...
        return lay;
}
Report クラスのコンストラクタ (LinearLayout を拡張) は次のようになります。
    public Report(Context context) {
    super(context);
    this.context = context;
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.activity_report, null);
    this.addView(view);
    Button button = new Button(context);
    button.setText("LinearLayoutExtended");
    this.addView(button);
問題; R.layout.activity_report から取得しているビューは、画面上に非常に小さな幅で表示されます。ただし、その下のボタンは、必要な幅を取得します。
activity_report.xml には、塗りつぶしの親の幅と高さがあり、テキストボックス、ボタン、その他のもので満たされた水平レイアウトから始まります。Activity_report.xml は、Eclipse のプレビューで見栄えがよく、以前にアクティビティに使用したときも見栄えがよくなりました。
this.addView(view) を使用してレイアウト activity_report.xml を追加し、それを画面全体に表示できないのはなぜですか? (現在のように狭い幅ではありません)