• Android 多状态按钮 ToggleButton


    ToggleButton
         选中状态,未选中状态并且需要为不同的状态设置不同的显示文本。
         属性:
              checked="true"
              textOff=""
              textOn=""
     
    private ToggleButton tb ;
    private ImageView iv ;
         tb=(ToggleButton) findViewById(R.id.toggleButton1);
          iv=(ImageView) findViewById(R.id. imageView1);
          //给togglebutton 设置监听器
          tb.setOnCheckedChangeListener( new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
               /*
                *  当TB被点击的时候,当前的方法会被执行
                *  buttonView  代表被点击的控件的本事(对象)
                *  isChecked  代表被点击的控件的状态(On/Off)
                */
                 iv.setImageResource(isChecked?R.drawable. on:R.drawable.ic_launcher);
             }
          });
         
     
     
     
     <ToggleButton
            android:id="@+id/toggleButton1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textOn="@string/textOn"
            android:textOff="@string/textOff"
            android:hint="@string/ToggleButton" />
     
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:src="@drawable/ic_launcher" />
    stareblankly.cn
  • 相关阅读:
    redis_ 5 集群
    redis_4 主从模式
    redis_3 持久化
    redis_2 数据类型
    linux_ubuntu 连接xftp
    redis_1 安装和简单使用
    Activiti 各个节点涉及的表
    oracle 数据库imp操作导入dmp文件时表空间问题
    ORA-27101: shared memory realm does not exist 错误的处理
    oralce清理user 和tablespace.
  • 原文地址:https://www.cnblogs.com/stareblankly/p/4829249.html
Copyright © 2020-2023  润新知