In my application I am using the following means to render/generate the views to a view pager. Yes it works fine and as expected.
Note :- But here I have seen that this method has to put a lot of effort in terms of Android resources ( associated with the device). I want to find out any optimized way to do the same. Is there is any? Suggest me or the above is good ?
class MyActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layoutView);
LinearLayout pageFirst = getPageFisrt(context);
LinearLayout pageSecond = getPageSecond(context);
LinearLayout pageThird = getPageThird(context);
LinearLayout pageFourth = getPageFourth(context);
.........
.........
pageArrayList = new ArrayList<LinearLayout>();
pageArrayList.clear();
pageArrayList.add(pageFirst);
pageArrayList.add(pageSecond);
pageArrayList.add(pageThird);
pageArrayList.add(pageFourth);
...........
..........
viewPager.setAdapter(new MatchDetailsPagerAdapter(
context, pageArrayList));
indicator.setViewPager(viewPagerMatchDetailMain);
}
}
and for each page I inflated the layout from resource, like
private LinearLayout getPageFisrt(Context context) {
// TODO Auto-generated method stub
LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout linearLayoutFirstPage = (LinearLayout) inflater.inflate(
R.layout.pager_first_large_views, null);
// performing action on the page child layout.
return linearLayoutFirstPage;
}
Looking forward for a better approach to do the same