Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k 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 Reply

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

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

</RelativeLayout>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...