views:

10

answers:

1

Hi!

I have a srange trouble wit the ListView: I've created the compound control

public class TopicControl extends LinearLayout
....

<merge xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    <LinearLayout
        android:id="@+id/llTopicHeader"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
    >
        <Button 
            android:id="@+id/btnTopicTitle"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:tag="btnTopicTitle"
        ></Button>
        <LinearLayout
            android:id="@+id/llTopicBar"
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"
            android:visibility="invisible"
            android:tag="llTopicBar"
        >
            <Button
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:background="@drawable/bar_calendar"
            ></Button>
            <Button
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:background="@drawable/bar_person"
            ></Button>
        </LinearLayout>
    </LinearLayout>
    <TextView 
        android:id="@+id/tvTopicText"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
    ></TextView>
</merge>

In that control I implemented hiding/showing llTopicBar on btnTopicTitle click.

The problem is that when I add that component to ListView, after pressing btnTopicTitle, llTopicBar becomes visible not only for the clicked item, but for every second LstViewItem.

after adding "parent" verification llTopicBar becomes visible for every 4th item in the ListView.

Override
public void onClick(View v)
{
    if (v.getParent().getParent() == getThis())
    llTopicBar.setVisibility(llTopicBar.getVisibility() == View.VISIBLE ? View.INVISIBLE : View.VISIBLE);
}

Could you please help me with that problem?

A: 

The problem was within reusing Views for ListView during scrolling.

bivy