listview里子项有按钮的情况

你自定义按钮:

public class MyButton extends Button {

    public DontPressWithParentImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void setPressed(boolean pressed) {
        // If the parent is pressed, do not set to pressed.
        if (pressed && ((View) getParent()).isPressed()) {
            return;
        }
        super.setPressed(pressed);
    }
}

然后在布局人间中这样引用:

  
<your.name.customview.MyButton
 android:id="@+id/mybutton"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
/>
原文地址:https://www.cnblogs.com/ct732003684/p/2944641.html