title: Rendering Views to View Pager - Optimized Way
body: <p>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.</p>
  
  <p><em><strong>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 ?</em></strong></p>
  
  <pre><code>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&lt;LinearLayout&gt;();
              pageArrayList.clear();
  
              pageArrayList.add(pageFirst);
              pageArrayList.add(pageSecond);
              pageArrayList.add(pageThird);
              pageArrayList.add(pageFourth);
              ...........
              ..........
  
              viewPager.setAdapter(new MatchDetailsPagerAdapter(
                      context, pageArrayList));
  
              indicator.setViewPager(viewPagerMatchDetailMain);
  
          }
  
      }
  </code></pre>
  
  <p>and for each page I inflated the layout from resource,
  like</p>
  
  <pre><code>   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;
      }
  </code></pre>
  
  <p><em><strong>Looking forward for a better approach to do the same</em></strong></p>