So far I\'ve been hacking together examples to get a feel for the APIs the Android SDK as a whole. However, I\'ve hit an impasse.
I\'m trying to Inflate a LinearLay
I've recently implemented this and this is my instantiateItem method (made it a bit minimal for readability.
@Override
public Object instantiateItem(View collection, int position) {
Evaluation evaluation = evaluations.get(position);
View layout = inflater.inflate(R.layout.layout_evaluation, null);
TextView evaluationSummary = (TextView) layout.findViewById(R.id.evaluation_summary);
evaluationSummary.setText(evaluation.getEvaluationSummary());
((ViewPager) collection).addView(layout);
return layout;
}
@Override
public void destroyItem(View collection, int position, Object view) {
((ViewPager) collection).removeView((View) view);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
So for the page that is displayed, I get the data from my evaluations list using the position as the index.
Then inflate the Layout which has the views I will add my data too.
Then I get the TextView to set the evaluation summary text on.
Then the whole Layout is added to the ViewPager.
And finally the Layout is also returned.
If you still can't get it post your code.