一、xml布局
""
xmlns:tools=""
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingbottom="@dimen/activity_vertical_margin"
android:paddingleft="@dimen/activity_horizontal_margin"
android:paddingright="@dimen/activity_horizontal_margin"
android:paddingtop="@dimen/activity_vertical_margin"
tools:context=".mainactivity" >
"@+id/lv"
android:layout_width="match_parent"
android:layout_height="300dp"
android:divider="#ccc"
android:dividerheight="2dp" />
"@+id/cb_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/lv"
android:layout_margintop="20dp"
android:text="全選" />
"@+id/cb_fanxuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/cb_all"
android:layout_margintop="20dp"
android:text="反選" />
二、activity**(主要處理全選和反選按鈕)
public
class
mainactivity
extends
activity
// 更新adapter
adapter.notifydatasetchanged();
} else
// 更新adapter
adapter.notifydatasetchanged();}}
});/**
**反選按鈕事件
*/cb_fanxuan.setoncheckedchangelistener(new oncheckedchangelistener()
} else
}// 更新adapter
adapter.notifydatasetchanged();
}});
}/**
**準備資料
*/private
void
initdata() }}
三、介面卡myadapter(主要方法getview()處理)
@override
public view getview(final int position, view convertview, viewgroup parent)
});return view;
}
四、例項
全選 不選和反選
今天我們來學習一下如何實現全選 不選和反選,首先我們來看一張收件箱的。收件箱如果只是簡單的刪除幾封郵件,選中刪除就可以了,但是如果郵箱裡堆滿了郵件,乙個乙個的選中再刪除,太過於浪費精力。今天你學會了如何實現全選 不選和反選,就可以不花精力的刪掉過期的郵件。接下來我們看效果圖。沒被選中之前 全選 不選...
js反選 全選
js的寫法在標題行增加全選核取方塊和反選按鈕,在 資料行增加帶name屬性的核取方塊。type checkbox id checkall nclick checkall type button value 反選 nclick inversechk 主鍵序號 var recruit name chec...
jquery全選 反選
function a flag 改變select的text ddlyeargroup 0 options 0 text all 其他參考 ddlstep empty 清空 ddlstep attr value 9 根據value選擇 ddlstep 0 selectedindex 1 select下...