title: Android - List of labels in a fragment, wrong display when scrolling
body: <p>So here's my problem.</p>
  
  <p>I'm working on API 14, I made a "MasterDetailFlow" with the help of Eclipse.
  On the left part of the "twopane", I have some textviews, and a fragment.
  (I made it simple)</p>
  
  <pre><code>&lt;LinearLayout 
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:baselineAligned="false"
      android:orientation="horizontal"
      tools:context=".ListActivity" &gt;
  
      &lt;RelativeLayout
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:layout_weight="27"
          android:orientation="vertical" &gt;
          &lt;TextView
                android:text="toto" 
              /&gt;
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="textView"/&gt;
  
            &lt;fragment
                android:id="@+id/fragment1"
                android:name=""
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="button"
                /&gt;
      &lt;/RelativeLayout&gt;
      //the right part of the screen, doesn't matter
      &lt;FrameLayout
           /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The Fragment class is like that</p>
  
  <pre><code>public class MyFragment extends Fragment {
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = null;
  
          if (mItem != null) {
                  if(mItem.isTrue){
                  rootView = inflater.inflate(layout1, container, false);
              }else{
                  rootView = inflater.inflate(layout2, container, false);
                  }
          }
      }
  }
  </code></pre>
  
  <p>I dynamically add items in the list with a ArrayAdapter.
  The thing is : When the list doesn't need to be scrolled (the height of the list is smaller than the height of the fragment), everything is displayed the good way.
  But when the list is bigger (the visible part is OK) and I scroll the list, some items which should have the layout1 have the layout2, and the other way.
  Those items are weirdly always at the junction, like the first element hidden.
  And when you click on the item, it act normally. For exemple, a item that should be layout1 (but is displayed layout2) act as an item layout1 on click.
  I don't know if it's clear, because it's not to me :)</p>
  
  <p>And when I print in logcat the list of Strings which is in the fragment, it's in the good order. So it looks like a "display error" only, but where does it come from?</p>
  
  <p>Does anyone have some similar problem? Know the issue?</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>Here is my Custom ArrayAdapter. I don't have the methods getItemViewType and getViewTypeCount, I should work on that.
  Till now I was using a boolean stored in the DummyItem to know if it's a type 1 item or a type 2.</p>
  
  <pre><code>    public class CustomArrayAdapter extends ArrayAdapter&lt;DummyItem&gt;
      @Override
          public View getView(int p_position, View p_convertView, ViewGroup p_parent) {
              DummyItem item = data.get(p_position);
              View row = p_convertView;
              if(row==null){
              if(item.isTrue){
              LayoutInflater inflater = ((Activity)m_context).getLayoutInflater();
              row = inflater.inflate(layoutResourceId, p_parent, false);
              row.setTag(item);
              TextView label1 = (TextView) row.findViewById(textViewId);
              label1.setText(item.content);
  
  
                  }else{
                      LayoutInflater inflater = ((Activity)m_context).getLayoutInflater();
  
                      row = inflater.inflate(R.layout.simple_list_item_activated_1_custom, p_parent, false);
                      TextView label2 = (TextView) row.findViewById(R.id.text1);
                      labelPiece.setText(item.content);
  
  
                  }
  
  
              }else{
              }
  
              return row;
          }
      }
  </code></pre>