title: stackoverflow error in viewpager fragments
body: <p>I am working on an android application. I have attached 8 fragments with one viewpager for swipe. Its working but when swiping stackoverflow error comes.The following is my fragmentactivity.</p>
  
  <pre><code>public class HomeScreen extends FragmentActivity {
  
  public InsuranceFragmentAdapter mAdapter;
  private ViewPager mPager;
  
  public String value;
  public PageIndicator mIndicator;
  public static int cPosition = 0;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.themed_circles);
  
      mAdapter = new InsuranceFragmentAdapter(getSupportFragmentManager(),
              HomeScreen.this);
  
      mPager = (ViewPager) findViewById(R.id.pager);
      mPager.setAdapter(mAdapter);
  
      mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
      mIndicator.setViewPager(mPager);
      // mIndicator.setCurrentItem(2);
  
      mIndicator
              .setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  
  
                  @Override
                  public void onPageSelected(int position) {
  
                  }
  
                  @Override
                  public void onPageScrolled(int position,
                          float positionOffset, int positionOffsetPixels) {
  
                  }
  
                  @Override
                  public void onPageScrollStateChanged(int state) {
  
                  }
              });
  
  
  }
  
  }
  </code></pre>
  
  <p>and my adapter class is the following</p>
  
  <pre><code>public class InsuranceFragmentAdapter extends FragmentPagerAdapter {
  Context contx;
  
  
  public InsuranceFragmentAdapter(FragmentManager fm, Context ctx) {
  
      super(fm);
      this.contx = ctx;
  
  
  }
  
  @Override
  public Fragment getItem(int position) {
      Fragment fragment = null;
      switch (position) {
      case 0:
          fragment = Fragment.instantiate(contx, com.lic.fragments.FragmentPolicyListing.class.getName());
          break;
      case 1:
          fragment = Fragment.instantiate(contx, com.lic.fragments.FragmentBasicPersonal.class.getName());
          break;
  
  
      case 2:
          fragment = Fragment.instantiate(contx, com.lic.fragments.FragmentationNomineeDetails.class.getName());
          break;
      case 3:
          fragment = Fragment.instantiate(contx, com.lic.fragments.FragmentFamilyHistory.class.getName());
          break;
  
      case 4:
          fragment = Fragment.instantiate(contx, com.lic.fragments.FragmentPolicyDetails.class.getName());
          break;
  
      case 5:
          fragment = Fragment.instantiate(contx, com.lic.fragments.FragmentFemale.class.getName());
          break;
      case 6:
          fragment = Fragment.instantiate(contx, com.lic.fragments.Fragmentmedical.class.getName());
          break;
      case 7:
          fragment = Fragment.instantiate(contx, com.lic.fragments.FragmentCheckList.class.getName());
          break;
      }
  
      return fragment;
  }
  
  @Override
  public int getCount() {
      // Show 3 total pages.
      return 8;
  }
  
  // @Override
  // public CharSequence getPageTitle(int position) {
  // return TestFragmentAdapter.CONTENT[position % CONTENT.length];
  // }
  
  // @Override
  // public int getIconResId(int index) {
  // return ICONS[index % ICONS.length];
  // }
  
  public void setCount(int count) {
      // if (count &gt; 0 &amp;&amp; count &lt;= 10) {
      // mCount = count;
      // notifyDataSetChanged();
      // }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>ANd one of my fragment class is the following</p>
  
  <pre><code>public class FragmentationNomineeDetails extends Fragment {
  
  
  private String nominNameStr;
  private String nomindobStr;
  private String nominageStr;
  private String nominrelationshipStr;
  private EditText nomini_name_et;
  private TextView nomi_dob_tv;
  private EditText nomi_age_et;
  private EditText nomi_relationship_et;
  private View layout;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
   layout = inflater.inflate(R.layout.fragment_nomination_details,
              container, false);
      Button save = (Button) layout.findViewById(R.id.save);
      nomini_name_et = (EditText) layout
              .findViewById(R.id.nomini_name_et);
      nomi_dob_tv = (TextView) layout.findViewById(R.id.nomi_dob_tv);
      nomi_age_et = (EditText) layout.findViewById(R.id.nomi_age_et);
      nomi_relationship_et = (EditText) layout.findViewById(R.id.nomi_relationship_et);
      setlistener();
  
  
      return layout;
  }
  
  
  @Override
  public void onDestroyView() {
      // TODO Auto-generated method stub
      super.onDestroyView();
      layout=null;
  }
  }
  </code></pre>
  
  <p>Its working. I can swipe to any fragment but with in 4 or 5 swipe stackoverflow error occurs.
  The below is my logcat.</p>
  
  <pre><code>02-21 14:45:02.817: E/AndroidRuntime(24463): FATAL EXCEPTION: main
  02-21 14:45:02.817: E/AndroidRuntime(24463): java.lang.StackOverflowError
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.widget.Editor.drawHardwareAccelerated(Editor.java:1664)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.widget.Editor.onDraw(Editor.java:1563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.widget.TextView.onDraw(TextView.java:5974)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14853)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14856)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14856)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14856)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.widget.FrameLayout.draw(FrameLayout.java:467)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.widget.ScrollView.draw(ScrollView.java:2276)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14856)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14856)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13739)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14856)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.support.v4.view.ViewPager.draw(ViewPager.java:2157)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)    
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13739)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14856)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.widget.FrameLayout.draw(FrameLayout.java:467)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14856)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13744)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3153)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13739)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.getDisplayList(View.java:13786)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at android.view.View.draw(View.java:14563)
  02-21 14:45:02.817: E/AndroidRuntime(24463):    at       android.view.ViewGroup.drawChild(ViewGroup.java:3316)
  </code></pre>
  
  <p>I am posting one of my fragments xml file.please have a look and let me know any issues with it.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;com.lic.helper.CommonHeader
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" &gt;
  &lt;/com.lic.helper.CommonHeader&gt;
   &lt;RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="10dp"
      android:background="@color/gray_bg_container"
      android:padding="1dp" &gt;
  
      &lt;RelativeLayout
          android:id="@+id/relatve_top"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_marginLeft="5dp"
          android:layout_marginRight="5dp"
          android:background="@drawable/gray_top_round_background"
          android:padding="8dp" &gt;
  
          &lt;TextView
              android:id="@+id/textView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_centerVertical="true"
              android:layout_marginLeft="5dp"
              android:text="Nomination Details"
              android:textColor="@color/white" /&gt;
      &lt;/RelativeLayout&gt;
  
  
  
  
       &lt;ScrollView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/relatve_top"
          android:layout_marginLeft="5dp"
          android:layout_marginRight="5dp"
          android:background="@drawable/bottom_rounded_white_layout" &gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="fill_parent"
              android:layout_margin="10dip"
              android:layout_marginTop="0dp"
              android:background="#F8F8F8"
              android:orientation="vertical" &gt;
  
  
  
              &lt;LinearLayout
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:background="#F1F0EE"
                  android:gravity="center"
                  android:orientation="horizontal"
                  android:weightSum="10" &gt;
  
                  &lt;ImageView
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="2.5"
                      android:padding="5dp"
                      android:src="@drawable/ic_name" /&gt;
  
                  &lt;EditText
                      android:id="@+id/nomini_name_et"
                      android:layout_width="0dp"
                      android:layout_height="match_parent"
                      android:layout_weight="7.5"
                      android:background="#fff"
                      android:hint="Nominees Name"
                      android:paddingLeft="5dp"
                      android:paddingRight="5dp"
                      android:textColor="#000" /&gt;
              &lt;/LinearLayout&gt;
  
              &lt;LinearLayout
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="2dp"
                  android:background="#F1F0EE"
                  android:gravity="center"
                  android:orientation="horizontal"
                  android:weightSum="10" &gt;
  
                  &lt;ImageView
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="2.5"
                      android:padding="5dp"
                      android:src="@drawable/ic_name" /&gt;
  
                  &lt;TextView
                      style="@android:style/Widget.EditText"
                      android:id="@+id/nomi_dob_tv"
                      android:layout_width="0dp"
                      android:layout_height="match_parent"
                      android:layout_weight="7.5"
                      android:background="#fff"
                      android:hint="Date of Birth"
                      android:paddingLeft="5dp"
                      android:paddingRight="5dp"
                      android:textColor="#000" 
                      android:clickable="true"/&gt;
              &lt;/LinearLayout&gt;
  
  
  
  
  
              &lt;LinearLayout
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="2dp"
                  android:background="#F1F0EE"
                  android:gravity="center"
                  android:orientation="horizontal"
                  android:weightSum="10" &gt;
  
                  &lt;ImageView
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="2.5"
                      android:padding="5dp"
                      android:src="@drawable/ic_location" /&gt;
  
                  &lt;EditText
                      android:id="@+id/nomi_age_et"
                      android:layout_width="0dp"
                      android:layout_height="match_parent"
                      android:layout_weight="7.5"
                      android:background="#fff"
                      android:hint="Age"
                      android:paddingLeft="5dp"
                      android:paddingRight="5dp"
                      android:textColor="#000" /&gt;
              &lt;/LinearLayout&gt;
  
               &lt;LinearLayout
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginTop="2dp"
                  android:background="#F1F0EE"
                  android:gravity="center"
                  android:orientation="horizontal"
                  android:weightSum="10" &gt;
  
                  &lt;ImageView
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      android:layout_weight="2.5"
                      android:padding="5dp"
                      android:src="@drawable/ic_location" /&gt;
  
                  &lt;EditText
                      android:id="@+id/nomi_relationship_et"
                      android:layout_width="0dp"
                      android:layout_height="match_parent"
                      android:layout_weight="7.5"
                      android:background="#fff"
                      android:hint="Relationship"
                      android:paddingLeft="5dp"
                      android:paddingRight="5dp"
                      android:textColor="#000" /&gt;
              &lt;/LinearLayout&gt;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
              &lt;RelativeLayout
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginBottom="20dp" &gt;
  
                  &lt;Button
                      android:id="@+id/save"
                      android:layout_width="fill_parent"
                      android:layout_height="50dp"
                      android:layout_alignParentBottom="true"
                      android:layout_marginBottom="12dp"
                      android:layout_marginLeft="5dp"
                      android:layout_marginRight="5dp"
                      android:padding="8dp"
                      android:layout_marginTop="5dp"
                      android:background="@drawable/rounded_orange_button_bg"
                      android:text="@string/save"
                      android:textColor="#fff" /&gt;
              &lt;/RelativeLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/ScrollView&gt;
  
  
  
  
  
  
  
      &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>