你好,游客 登录
背景:
阅读新闻

【Android每日一讲】2012.11.19 我同意条款 -

[日期:2013-04-12] 来源:  作者: [字体: ]

1. 范例说明

 

  • 该范例将设计一个TextView放入条款文字,在下方配置一个CheckBox Widget作为选取项,通过Button.onClickListener按钮处理事件,取得User同意条款状态。
  • 当CheckBox.isChecked为true时,更改TextView的文字内容为“你已接受同意!!”,当未选取CheckBox时,Button则是不可以被点击的。

 

2. 运行结果

3. 编写代码

 

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);
				}
			}
		});

 

4. 扩展学习与作业

 

CheckBox的Refrence

http://developer.android.com/reference/android/widget/CheckBox.html

 

5.视频讲解
http://www.eyeandroid.com/thread-10470-1-1.html






收藏 推荐 打印 | 录入:admin | 阅读:
相关新闻