当前位置: 首页 > news >正文

怎么推广网站链接sem网站建设

怎么推广网站链接,sem网站建设,上海自助建网站,深圳知名包装设计公司CheckBox选择Or不选#xff0c;是个问题#xff01; 前言 前面我们讲过了RadioButton与RadioGroup#xff0c;利用单选按钮组的属性来实现仿微信底部Tab切换的效果。对比记忆一下#xff0c;今天我们来讲解第二个类似的控件CheckBox#xff0c;按照惯例先看下它的类继承…CheckBox选择Or不选是个问题 前言 前面我们讲过了RadioButton与RadioGroup利用单选按钮组的属性来实现仿微信底部Tab切换的效果。对比记忆一下今天我们来讲解第二个类似的控件CheckBox按照惯例先看下它的类继承关系如下 public class CheckBox extends CompoundButton java.lang.Object↳ android.view.View↳ android.widget.TextView↳ android.widget.Button↳ android.widget.CompoundButton↳ android.widget.CheckBox我们发现CheckBox与RadioButton有相同的继承关系所以CheckBox也是一个具有选中效果的控件通常我们称它为**复选框**。 基本使用 先来展示一段代码展示下效果。 ?xml version1.0 encodingutf-8? android.support.constraint.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentCheckBoxapp:layout_constraintHorizontal_chainStylepackedandroid:idid/cb_hobbyandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:checkedtrueapp:layout_constraintRight_toLeftOfid/tv_hobbyapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintLeft_toLeftOfparentapp:layout_constraintTop_toTopOfparent /TextViewandroid:idid/tv_hobbyandroid:layout_widthwrap_contentandroid:layout_marginLeft5dpandroid:layout_heightwrap_contentapp:layout_constraintTop_toTopOfparentapp:layout_constraintBottom_toBottomOfparentapp:layout_constraintLeft_toRightOfid/cb_hobbyandroid:text游泳app:layout_constraintRight_toRightOfparent / /android.support.constraint.ConstraintLayout这里我们使用了前面博文内容讲到的ConstraintLayout实现了CheckBox和TextView一起居中整个父布局的效果。如果你还不是很熟悉这个约束布局如何使用可以查看之前博文内容《布局大杀器—ConstraintLayout》 实现效果如图所示 这里默认设置CheckBox的checked属性为true则表示默认选中那么在页面中如何获取这个控件是否被选中呢当然是通过设置监听器这里附上代码 /*** 演示CheckBox等用法** author xmkh*/ public class CheckActivity extends AppCompatActivity {Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_check);CheckBox cbHobby findViewById(R.id.cb_hobby);final TextView tvHobby findViewById(R.id.tv_hobby);//设置复选框的勾选状态监听器cbHobby.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {Overridepublic void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {tvHobby.setText(isChecked ? 已选中 : 未选中);}});} } 实现效果如图所示 实践 实际效果中我们一般不会使用自带的样式同样的我们参照RadioButton的方式来给它设置一个UI样式。通常在注册界面总会看到是否同意《用户注册协议》的复选框如果要实现下图的样式我们怎么做呢 我们来仿照这个效果实现一下界面布局。 我们准备选中和未选中2个图片ic_login_agreement_check.png和ic_login_agreement_uncheck.png 在res/drawable/文件夹下新建一个样式文件selector_cb_login_agreement.xml 附上样式文件代码 ?xml version1.0 encodingutf-8? selector xmlns:androidhttp://schemas.android.com/apk/res/androiditem android:drawablemipmap/ic_login_agreement_check android:state_checkedtrue/item android:drawablemipmap/ic_login_agreement_uncheck / /selector设置CheckBox的Button样式完整代码如下 ?xml version1.0 encodingutf-8? android.support.constraint.ConstraintLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context.RegisterCheckActivity!--主要设置CheckBox的button样式为自定义的selector_cb_login_agreement即可--CheckBoxandroid:idid/cb_login_agreementapp:layout_constraintTop_toTopOfparentapp:layout_constraintBottom_toBottomOfparentandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:checkedtrueandroid:buttondrawable/selector_cb_login_agreementapp:layout_constraintEnd_toStartOfid/tv_login_agreementapp:layout_constraintHorizontal_chainStylepackedapp:layout_constraintStart_toStartOfparent /TextViewandroid:textColor#A6600Candroid:idid/tv_login_agreementandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text我已阅读并同意《XX用户注册协议》android:textSize18spapp:layout_constraintBottom_toBottomOfid/cb_login_agreementapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toEndOfid/cb_login_agreementapp:layout_constraintTop_toTopOfid/cb_login_agreement / /android.support.constraint.ConstraintLayout最终实现效果如图所示 结语 今天我们的CheckBox分享就到此结束啦希望各位小伙伴在学习Android基础控件的时候能够举一反三多思考、多练习。坚持下去相信你一定会从小白变成大牛的也欢迎各位小伙伴加入我们的微信技术交流群在公众号中回复微信群就可以加入其中也可以在公众号中回复视频里面有一些初学者视频哦~ PS:如果还有未看懂的小伙伴欢迎加入我们的QQ技术交流群892271582里面有各种大神回答小伙伴们遇到的问题我们的微信群马上也将要和大家见面啦届时希望大家踊跃加入其中~~
http://www.dnsts.com.cn/news/43156.html

相关文章:

  • 网站推广公司 优帮云建筑网建筑规范
  • 泸西县建设小学网站一起做网店 网站打不开
  • 一个一起做网站重庆做兼职哪个网站
  • 提供网站建设工具的品牌个人注册公司的条件
  • 衡水购物网站制作邯郸做网站流程
  • 成都最专业做网站的织梦cms破解版
  • 企业网站推广策划国外网站做营销
  • 做网站域名备案需要多久网络运营商ip地址
  • 国外网站在国内备案免费友情链接
  • 网站编辑建设企业手机网站设计
  • 网站建设行业解决方案时间线 wordpress
  • 公司注册如何网上核名手机关键词排名优化
  • 网站设计师工资怎样电商运营培训正规平台
  • 网站建设技术合作合同书专题定制网站建设
  • 国家拨款农村建设查询的网站温州营销推广公司
  • 陕西省住房建设厅网站做高端网站建设公司
  • 怎样做微信挂机平台网站网址链接
  • 昆明pc网站建设韩版做哪个网站好
  • 深圳做网站多少费用免费设计logo的工具
  • 网站型跟商城型关于教育网站的策划书
  • 郑州关键词网站优化排名2个wordpress
  • 杭州网站设计渠道软件开发实例
  • 素材下载网站源码wordpress 相册形式
  • 机械加工类网站wordpress阅读数 显示k
  • 广州网站制作知名 乐云践新做网站比特币钱包
  • 期货网站做模拟百度优化点击软件
  • 手机端网站设计北京未来广告公司
  • 网站怎么做最省钱广州专业网站制作平台
  • php做网站安性如何大连网站开发
  • 利用cms怎么做网站wordpress增加登陆注册