zoukankan      html  css  js  c++  java
  • Android checkBox

    checkBox
         状态:选中(true),未选中(false)
         属性:
              checked="true/false";
    private CheckBox  checkbox ;
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);
                  setContentView(R.layout. activity_main);
                   checkbox=(CheckBox) findViewById(R.id. checkbox);
                   //通过设置checkbox的监听事件来对checkbox是不是被选中。
                   //new一个匿名的内部类
                   checkbox.setOnCheckedChangeListener( new OnCheckedChangeListener() {
                          @Override
                          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                                // 通过onCheckedChanged来监听当前的 checkbox是否被选中
                                if(isChecked){
                                      String text=checkbox.getText().toString();
                                      Log. i("tag", text );
                               }
                         }
                  });
           }
     
     
     <CheckBox
            android:checked ="true"
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="CheckBox" />
    stareblankly.cn
  • 相关阅读:
    计算机网络第一章_20210512
    bootloader_华清远见
    C#3.17
    linux--cd命令
    国内的开源网站
    安装linux
    如何自我介绍
    课堂破冰游戏“猜猜他是谁”
    办公软件---word
    计算机网络--技能训练
  • 原文地址:https://www.cnblogs.com/stareblankly/p/4829243.html
Copyright © 2011-2022 走看看