listview里子项有按钮的情况使用介绍
程序员文章站
2023-11-29 09:04:10
你自定义按钮: 复制代码 代码如下: public class mybutton extends button { public dontpresswithparentim...
你自定义按钮:
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"
/>
复制代码 代码如下:
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"
/>
上一篇: sqlserver获取各种形式的时间