listview里子项有按钮的情况使用介绍
只要你有一台电脑或者手机,都能关注图老师为大家精心推荐的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"
/


