listview里子项有按钮的情况使用介绍
更新时间:2013年03月05日 17:07:34 作者:
不知大家有没有遇到过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"
/>
复制代码 代码如下:
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"
/>
相关文章
详解基于Android的Appium+Python自动化脚本编写
这篇文章主要介绍了详解基于Android的Appium+Python自动化脚本编写,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2020-08-08
Android项目类似淘宝 电商 搜索功能,监听软键盘搜索事件,延迟自动搜索,以及时间排序的搜索历史记录的实现
本篇文章主要介绍了Android实现类似淘宝、电商、搜索功能(监听软键盘搜索事件,延迟自动搜索,以及时间排序的搜索历史记录),感兴趣的小伙伴们可以参考一下。2016-10-10


最新评论