Android Studio ToggleButton 使用

来源:互联网 发布:数据挖掘就业方向 编辑:程序博客网 时间:2024/05/29 07:42




xml文件:

 <ToggleButton

            android:checked="false"
            android:id="@+id/igbt1"
            android:background="@null"
            android:button="@mipmap/set_switch_off"
            android:layout_gravity="center"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:textOn=""
            android:textOff=""

            />

部分java代码:

首先实现CompoundButton.OnCheckedChangeListener接口,重写onCheckedChanged方法。

……

private ToggleButton igbt1;初始化

……

igbt1.setOnCheckedChangeListener(this);调用方法
原创粉丝点击