慕课网--checkbox

本文提供了一个使用 Android CheckBox 控件的示例应用。该应用通过 XML 布局文件定义了三个 CheckBox,并在 Java 代码中为它们添加了监听器,以记录用户的选择状态变化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.test_checkbox.MainActivity" >

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="篮球" />

    <CheckBox
        android:id="@+id/checkBox2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/checkBox1"
        android:layout_below="@+id/checkBox1"
        android:layout_marginTop="21dp"
        android:text="足球" />

    <CheckBox
        android:id="@+id/checkBox3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/checkBox2"
        android:layout_below="@+id/checkBox2"
        android:layout_marginTop="39dp"
        android:checked="true"
        android:text="羽毛球" />

</RelativeLayout>

package com.example.test_checkbox;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class MainActivity extends Activity implements OnCheckedChangeListener{


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		final CheckBox cb_1;
		final CheckBox cb_2;
		final CheckBox cb_3;
		
		cb_1 = (CheckBox) findViewById(R.id.checkBox1);
		cb_2 = (CheckBox) findViewById(R.id.checkBox2);
		cb_3 = (CheckBox) findViewById(R.id.checkBox3);
		
		cb_1.setOnCheckedChangeListener(this);
		cb_2.setOnCheckedChangeListener(this);
		cb_3.setOnCheckedChangeListener(this);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
	@Override
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		String mText = buttonView.getText().toString();
		if(isChecked){
			Log.i("log", "已选中"+mText);	
		}else{
			Log.i("log", "已取消选中"+mText);	
		}
		
	}
}


内容概要:本文档《opencv高频面试题.docx》涵盖了OpenCV的基础概念、图像处理操作、特征提取与匹配、目标检测与机器学习、实际编程题、性能优化以及进阶问题。首先介绍了OpenCV作为开源计算机视觉库,支持图像/视频处理、目标检测、机器学习等领域,应用于安防、自动驾驶、医学影像、AR/VR等方面。接着详细讲述了图像的存储格式(如Mat类)、通道的概念及其转换方法。在图像处理部分,讲解了图像灰度化、二值化、边缘检测等技术。特征提取方面,对比了Harris和Shi-Tomasi角点检测算法,以及SIFT、SURF、ORB的特征提取原理和优缺点。目标检测部分介绍了Haar级联检测原理,并阐述了如何调用深度学习模型进行目标检测。文档还提供了几个实际编程题示例,如读取并显示图像、图像旋转、绘制矩形框并保存等。最后,探讨了性能优化的方法,如使用cv2.UMat(GPU加速)、减少循环等,以及相机标定、光流等进阶问题。 适合人群:对计算机视觉有一定兴趣,具备一定编程基础的学习者或从业者。 使用场景及目标:①帮助学习者掌握OpenCV的基本概念和技术;②为面试准备提供参考;③为实际项目开发提供技术指导。 阅读建议:由于内容涵盖广泛,建议读者根据自身需求有选择地深入学习相关章节,并结合实际编程练习加深理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值