1效果图
2MainActivity对应的布局activity_main
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#0066FF"
>
<CheckBox
android:id="@+id/cbQuanxuan"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="全选"
/>
<Button
android:id="@+id/btnQueding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="确定"
/>
</RelativeLayout>
<ListView
android:id="@+id/lvTest"
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</LinearLayout>
3MainActivity中
package com.zhh.mycheckbox;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
im