Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

android - listview item with clickable subview sometime can't pass the click event to the item's subview

I have a list view , each item has a clickable textview, when I click the textview, then change it into two buttons, if I click the outside of the textview I need the whole item can respond to click event.

I still have a worker thread to get something from internet, then update the listview. When a worker thread notify the list view's adapter notifydatasetchange, and at the same time, I click the textview in a item of the list, but strange things happen, I click the textview but the whole item respond to the click.

I know this is caused by listview' recycle mechanism. At the normal sitituation, when notifydatasetchanged, the listview will give up the event posted before. But some times it doesn't give up. But I want to know is there some workround to avoid this? I hope the listview's item can abandon the event that posted before notifydatasetchange.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
<RelativeLayout
    …
    android:descendantFocusability="blocksDescendants"
>

    <Button
        …
        android:focusable="false"
    />

</RelativeLayout>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...