listview里子項有按鈕的情況使用介紹
更新時間:2013年03月05日 17:07:34 作者:
不知大家有沒有遇到過listview里子項有按鈕的情況哈,本文自定義了按鈕并且在布局中做了引用,適合初學(xué)者哦,感興趣的也可以了解下
你自定義按鈕:
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"
/>
復(fù)制代碼 代碼如下:
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);
}
}
然后在布局人間中這樣引用:
復(fù)制代碼 代碼如下:
<your.name.customview.MyButton
android:id="@+id/mybutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
相關(guān)文章
Android 通過當(dāng)前經(jīng)緯度獲得城市的實例代碼
Android 通過當(dāng)前經(jīng)緯度獲得城市的實例代碼,需要的朋友可以參考一下2013-06-06Android TextView顯示Html類解析的網(wǎng)頁和圖片及自定義標(biāo)簽用法示例
這篇文章主要介紹了Android TextView顯示Html類解析的網(wǎng)頁和圖片及自定義標(biāo)簽用法,實例分析了Android中TextView控件的使用技巧,需要的朋友可以參考下2016-07-07Android實現(xiàn)側(cè)滑菜單DrawerLayout
這篇文章主要為大家詳細介紹了Android實現(xiàn)側(cè)滑菜單DrawerLayout,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-05-05