ListView with a TextEdit header messes up
<p>I have a ListView, and I have added a header (with getListView().addHeaderView) that simply contains a TextEdit widget.</p>

<p><img src="http://i.stack.imgur.com/7JcVi.png" alt="enter image description here"></p>

<p>Then when I tap the TextEdit to start writting, the keyboard appears and it messes up the list!
<img src="http://i.stack.imgur.com/LnJ8A.png" alt="enter image description here"></p>

<p>If I tap everywhere else to hide the keyboard, the list messes up again!</p>

<p>I don't know why is this happening. I thought it was something related with the onConfigurationChanged method, but after implementing it (and adding the corresponding attribute in the manifest file) the problem persists.</p>

<p>How could I fix it? Why is Android messing up my list?</p>

<p><strong>EDIT:</strong></p>

<p>My list uses a custom adapter, this is the getView method:</p>

<pre><code>@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;

    if (v != null) {
        return v;
    }

    LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    v = vi.inflate(R.layout.list_row, null);

    ListTask list_item = items.get(position);

    if (list_item != null) {
        TextView item_name = (TextView) v.findViewById(R.id.item_name);
        item_name.setText(list_item.getTitle());
    }

    return v;
}
</code></pre>

<p>The problem is not the value of my items, but their order. They are displayed in a different order when the keyboard appears, but the values are correct.</p>

<p><strong>EDIT2:</strong></p>

<p>Ok, I have changed my getView method with rekaszeru's suggestion and now it works as expected. But now I'm facing another problem: <strong>what if my items have two textviews?</strong></p>

<p>Let's say the second textview is optional, and "Item 1" and "Item 3" have it, but "Item 2" does not, so it's initialized as a void String (length == 0).
The first time the list is displayed, it shows "Item1" and "Item 3" with their second textview, and "Item 2" without it. That's correct. But when the keyboard appears, the "Item 2" takes the second textview of another item and displays it!</p>

<p>This is the modified code I have right now:</p>

<pre><code>@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater vi = (LayoutInflater) getContext().
            getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.list_row, null);
    }

    ListTask list_item = items.get(position);

    TextView item_name = (TextView) convertView.findViewById(R.id.item_name);
    TextView item_optional_text = (TextView) convertView.findViewById(R.id.item_optional_text);

    item_name.setText(list_item.getTitle());

    // if the item has defined the optional text, make some room and display it
    if (item_optional_text.isNotEmpty()) {
        LayoutParams layout_params = (LayoutParams) item_name.getLayoutParams();
        layout_params.topMargin = 10;
        layout_params.height = -2;  // -2: wrap_content
        item_name.setLayoutParams(layout_params);
        item_optional_text.setText(list_item.getOptionalText());
    }

    return convertView;
}
</code></pre>

<p>The isNotEmpty() does this in the Item class:</p>

<pre><code>public boolean isNotEmpty() {
    return this.optional_text.length() &gt; 0;
}
</code></pre>

<p>Maybe it's too complex to understand in a written question. If so, I can make a short video showing the problem and my source code. Thanks in advance for your help guys.</p>
