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
  • 相关阅读:
    Winfrom 动画实现
    Android-SD卡相关操作
    Android-动态权限获取
    Java 常用知识点
    无锁队列的实现
    稳定的快排
    设计模式
    map的线程安全
    win 消息
    memecpy源码
  • 原文地址:https://www.cnblogs.com/stareblankly/p/4829243.html
Copyright © 2011-2022 走看看