html5中文学习网

您的位置: 首页 > android » 正文

listview里子项有按钮的情况使用介绍_Android_脚本之家

[ ] 已经帮助:人解决问题
你自定义按钮
复制代码 代码如下:

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"
/>
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助