title: android.support.v4.view.ViewPager$LayoutParams cannot be cast to android.view.ViewGroup$MarginLayoutParams
body: <pre><code>mPagerAdapter = new PagerAdapter() {
          @Override
          public boolean isViewFromObject(View arg0, Object arg1) {
              return arg0 == arg1;
          }
  
          @Override
          public int getCount() {
              return views.size();
          }
  
          @Override
          public void destroyItem(View container, int position, Object object) {
              ((ViewPager)container).removeView(views.get(position));
          }
  
  
          @Override
          public Object instantiateItem(View container, int position) {
              ((ViewPager)container).addView(views.get(position));
              return views.get(position);
          }
      };
  
          mTabPager.setAdapter(mPagerAdapter);
  </code></pre>
  
  <blockquote>
    <p>After My Fragment has created,  I call function:</p>
  </blockquote>
  
  <pre><code>public void AddView(View v, int index)
  {
      views.add(index, v);
      mPagerAdapter.notifyDataSetChanged();
  }
  </code></pre>
  
  <blockquote>
    <p>But it report android.support.v4.view.ViewPager$LayoutParams cannot be cast to 
    android.view.ViewGroup$MarginLayoutParams</p>
  </blockquote>