zoukankan      html  css  js  c++  java
  • Android CheckBox 选择事件

    代码
    package com.demo;
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.CheckBox;
    import android.widget.CompoundButton;
    public  class MainMenu extends Activity implements  CompoundButton.OnCheckedChangeListener{

         CheckBox cb; 
        @Override
        
    protected void onCreate(Bundle savedInstanceState) {        
            
    super.onCreate(savedInstanceState);
            setContentView(R.layout.main); 
             
            cb
    =(CheckBox)findViewById(R.id.check); 
            cb.setOnCheckedChangeListener(
    this); 
        }


        
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            
    if (isChecked) { 
                cb.setText(
    "This checkbox is: checked"); 
              } 
              
    else { 
                cb.setText(
    "This checkbox is: unchecked"); 
              } 
            
        }
        
      

    }
    代码
    <?xml version="1.0" encoding="utf-8"?>

    <CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
     android:id
    ="@+id/check" 
     android:layout_width
    ="wrap_content"  
     android:layout_height
    ="wrap_content"  
     android:text
    ="This checkbox is: unchecked" /> 
     

  • 相关阅读:
    vue中mixins(混入)的使用
    js实现淘宝轮播图放大镜效果
    vue中的provide和inject
    vue自定义过滤器
    vue自定义指令
    HTTP和HTTPS详解
    可靠的TCP连接为何是三次握手和四次挥手
    跟着动画来学习TCP三次握手和四次挥手
    简单了解TCP/IP与HTTP
    网络协议
  • 原文地址:https://www.cnblogs.com/gwazy/p/1731163.html
Copyright © 2011-2022 走看看