今天遇到一个问题:ImageButton设置点击监听不起作用,不管我怎么点都没反应 :(
首先我一步步地排查控件id,代码逻辑,都没发现错误。然后……经过半个小时的纠结,突然发现设置了ImageButton下面的控件(自定义ListView)的width和height设置成了match_parent,把监听的控件给覆盖了,所以当然就点不到了……(整体布局是RelativeLayout,因为代码里还没写item,listview那块是一片空白,所以没发现)。
给自定义ListView加个属性 layout_below,把自定义的ListView放在ImageButton下面 就解决了!