首页 > 系统 > Android > 正文

listview里子项有按钮的情况使用介绍

2019-10-24 21:05:23
字体:
来源:转载
供稿:网友
不知大家有没有遇到过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" 
/> 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表