我同意条款---CheckBox的isChecked属性的使用

package irdc.ex04_04; 
import android.R.color;
import android.app.Activity; 
//import android.graphics.Color; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.CheckBox;
import android.widget.TextView; 
public class EX04_04 extends Activity 
{ 
  /** Called when the activity is first created. */ 


  /*声明 TextView、CheckBox、Button对象*/
  public TextView myTextView1; 
  public TextView myTextView2;
  public CheckBox myCheckBox; 
  public Button myButton; 
  
  @Override 
  public void onCreate(Bundle savedInstanceState) 
  { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    /*取得TextView、CheckBox、Button*/ 
    myTextView1 = (TextView) findViewById(R.id.myTextView1); 
    myTextView2 = (TextView) findViewById(R.id.myTextView2); 
    myCheckBox = (CheckBox) findViewById(R.id.myCheckBox);
    myButton = (Button) findViewById(R.id.myButton); 
    /*将CheckBox、Button预设为未选取状态*/ 
    myCheckBox.setChecked(false);
    myButton.setEnabled(false);
    
    //CharSequence hint = getString(R.string.hello);
    //myCheckBox.setHint(hint);
    //myCheckBox.setHintTextColor(color.RED);
    
    
    myCheckBox.setOnClickListener(new CheckBox.OnClickListener()
    { 
      @Override public void onClick(View v) 
      { 
        // TODO Auto-generated method stub 
        if(myCheckBox.isChecked())
        { 
          myButton.setEnabled(true);
          myTextView2.setText("");
          } 
        else 
        { 
          myButton.setEnabled(false); 
          myTextView1.setText(R.string.text1);
          /*在TextView2里显示出"请勾选我同意"*/
          myTextView2.setText(R.string.no);
        }
      }
      });
   myButton.setOnClickListener(new Button.OnClickListener()
    { 
     @Override 
     public void onClick(View v) 
    { 
      // TODO Auto-generated method stub 
      if(myCheckBox.isChecked()) 
      {
        myTextView1.setText(R.string.ok); 
      }
      else
      {   
      }
    } 
    });
    } 
}












el-table 是 Element UI 提供的表格组件,用于展示和处理大量数据。el-checkbox 是 Element UI 提供的复选框组件,用于实现多选功能。 在使用 el-table 时,首先需要引入相应的组件: ```javascript import { ElTable, ElTableColumn } from 'element-ui'; ``` 然后在模板中使用 el-table 组件: ```html <template> <div> <el-table :data="tableData"> <el-table-column prop="name" label="姓名"></el-table-column> <el-table-column prop="age" label="年龄"></el-table-column> <el-table-column prop="gender" label="性别"></el-table-column> </el-table> </div> </template> ``` 其中,:data 属性绑定了表格的数据,tableData 是一个数组,每个元素代表一行数据。el-table-column 用于定义表格的列,prop 属性指定了对应数据对象中的属性名,label 属性用于显示列标题。 接下来是 el-checkbox使用,同样需要引入相应的组件: ```javascript import { ElCheckbox, ElCheckboxGroup } from 'element-ui'; ``` 然后在模板中使用 el-checkbox 组件: ```html <template> <div> <el-checkbox-group v-model="selectedItems"> <el-checkbox v-for="item in checkboxOptions" :label="item.value" :key="item.id">{{ item.label }}</el-checkbox> </el-checkbox-group> </div> </template> ``` 其中,v-model 属性绑定了选中的复选框值,selectedItems 是一个数组,存储选中的复选框的值。el-checkbox-group 包裹多个 el-checkbox 组件,v-for 指令用于遍历 checkboxOptions 数组,:label 属性绑定每个复选框的值,:key 属性用于标识每个复选框。在 el-checkbox 组件内部,使用 {{ item.label }} 显示复选框的文本。 以上是 el-table 和 el-checkbox 的简单使用方法,根据实际需求可以进一步配置和定制。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值