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

济南免费网站建站模板wordpress先生

济南免费网站建站模板,wordpress先生,网站的建站方案,一级造价工程师准考证打印时间安卓自定义属性主要有3个步骤 在values文件夹新建attrs.xml文件中声明属性#xff0c;包括属性名和格式#xff0c;format常用属性有string ,integer,reference等 ?xml version1.0 encodingutf-8? resources!-- 声明属性集…安卓自定义属性主要有3个步骤 在values文件夹新建attrs.xml文件中声明属性包括属性名和格式format常用属性有string ,integer,reference等 ?xml version1.0 encodingutf-8? resources!-- 声明属性集的名称 --declare-styleable nameMyToggleButtton!-- 声明属性的name与类型 --attr namemy_background formatreference/attr namemy_slide_btn formatreference/attr namecurr_state formatboolean//declare-styleable/resources 在布局文件中使用使用之前必须先声明命名空间前面是固定不变的内容后面是包名. RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:zjhttp://schemas.android.com/apk/res/com.zj.switchbuttonxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parenttools:context${relativePackage}.${activityClass} com.zj.switchbutton.MyTrouggleButtonandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentzj:my_backgrounddrawable/switch_backgroundzj:my_slide_btndrawable/slide_buttonzj:curr_statetrue//RelativeLayout 在自定义view的构造方法中通过解析AttributeSet方法获得所需要的属性值,解析AttributeSet主要有两种方法 第一种:通过attrs.getAttributeValue获得 int countsattrs.getAttributeCount();for(int i0;icounts;i){attrs.getAttributeName(i);attrs.getAttributeValue(i);}public SettingItemView(Context context, AttributeSet attrs) {super(context, attrs);// TODO Auto-generated constructor stubiniView(context);String title attrs.getAttributeValue(http://schemas.android.com/apk/res/com.zj.mobilesafe, mytitle);desc_on attrs.getAttributeValue(http://schemas.android.com/apk/res/com.zj.mobilesafe, desc_on);desc_off attrs.getAttributeValue(http://schemas.android.com/apk/res/com.zj.mobilesafe, desc_off);tv_title.setText(title);setDesc(desc_off);} 第二种:通过TypedArray获得 public MyTrouggleButton(Context context, AttributeSet attrs) {super(context, attrs);// TODO Auto-generated constructor stub//获得自定义属性TypedArray tacontext.obtainStyledAttributes(attrs,R.styleable.MyToggleButtton);int Nta.getIndexCount();for(int i0;iN;i){int itemIdta.getIndex(i);switch (itemId) {case R.styleable.MyToggleButtton_curr_state:current_stateta.getBoolean(itemId, false);break;case R.styleable.MyToggleButtton_my_background:backgroundIDta.getResourceId(itemId, -1);if(backgroundID-1){throw new RuntimeException(请设置背景图片);}backgroundBitmapBitmapFactory.decodeResource(getResources(),backgroundID);break;case R.styleable.MyToggleButtton_my_slide_btn:slideButtonIDta.getResourceId(itemId, -1);if(backgroundID-1){throw new RuntimeException(请设置图片);}slideBtnBitmapBitmapFactory.decodeResource(getResources(), slideButtonID);default:break;}}init();}自定义属性到底有什么用呢当界面上的自定义元素有一些值需要改变并且大量重复的时候自定义属性可以有效的提高代码的重用性下面是一个简单的例子 声明属性 ?xml version1.0 encodingutf-8? resourcesdeclare-styleable nameTextViewattr namemytitle formatstring /attr namedesc_on formatstring /attr namedesc_off formatstring //declare-styleable /resources 在xml文件中定义 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:zjhttp://schemas.android.com/apk/res/com.zj.mobilesafeandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationvertical TextViewandroid:idid/textView1android:layout_widthfill_parentandroid:layout_height55dipandroid:background#8866ff00android:gravitycenterandroid:text设置中心android:textColor#000000android:textSize22sp /com.zj.mobilesafe.ui.SettingItemViewandroid:idid/siv_updateandroid:layout_widthwrap_contentandroid:layout_height65dipzj:desc_off设置自动更新已经关闭zj:desc_on设置自动更新已经开启zj:mytitle设置自动更新 /com.zj.mobilesafe.ui.SettingItemViewcom.zj.mobilesafe.ui.SettingItemViewandroid:idid/siv_show_addressandroid:layout_widthwrap_contentandroid:layout_height65dipzj:desc_off设置显示号码归属地已经关闭zj:desc_on设置显示号码归属地已经开启zj:mytitle设置显示号码归属地 /com.zj.mobilesafe.ui.SettingItemViewcom.zj.mobilesafe.ui.SettingClickViewandroid:idid/scv_changebgandroid:layout_widthwrap_contentandroid:layout_height65dip/com.zj.mobilesafe.ui.SettingClickViewcom.zj.mobilesafe.ui.SettingItemViewandroid:idid/siv_callsms_safeandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentzj:desc_off黑名单拦截已经关闭zj:desc_on黑名单拦截已经开启zj:mytitle黑名单拦截设置 /com.zj.mobilesafe.ui.SettingItemViewcom.zj.mobilesafe.ui.SettingItemViewandroid:idid/siv_watchdogandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentzj:desc_off看门狗已经关闭zj:desc_on看门狗已经开启zj:mytitle程序锁设置 /com.zj.mobilesafe.ui.SettingItemView/LinearLayout 解析属性并且改变属性 /*** 自定义的组合控件* author Administrator**/ public class SettingItemView extends RelativeLayout {private CheckBox cb_status;private TextView tv_desc;private TextView tv_title;private String desc_on;private String desc_off;/*** 初始化布局文件* param context*/private void iniView(Context context) {// TODO Auto-generated method stubView.inflate(context, R.layout.setting_item_view, SettingItemView.this);cb_status(CheckBox) this.findViewById(R.id.cb_status);tv_desc(TextView) this.findViewById(R.id.tv_desc);tv_title(TextView) this.findViewById(R.id.tv_title);}public SettingItemView(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);// TODO Auto-generated constructor stubiniView(context);}/*** 带有两个参数的构造方法,布局文件使用的时候调用 * param context* param attrs*/public SettingItemView(Context context, AttributeSet attrs) {super(context, attrs);// TODO Auto-generated constructor stubiniView(context);String title attrs.getAttributeValue(http://schemas.android.com/apk/res/com.zj.mobilesafe, mytitle);desc_on attrs.getAttributeValue(http://schemas.android.com/apk/res/com.zj.mobilesafe, desc_on);desc_off attrs.getAttributeValue(http://schemas.android.com/apk/res/com.zj.mobilesafe, desc_off);tv_title.setText(title);setDesc(desc_off);}public SettingItemView(Context context) {super(context);// TODO Auto-generated constructor stubiniView(context);}/*** * 检验组合和控件是否有焦点*/public boolean isChecked(){return cb_status.isChecked();}/*** 设置组合控件的是否选中*/public void setChecked(boolean checked){if(checked){setDesc(desc_on);}else{setDesc(desc_off);}cb_status.setChecked(checked);}/*** 组合控件 的内容发生改变* */public void setDesc(String text){tv_desc.setText(text);}} 效果如下
http://www.sadfv.cn/news/90284/

相关文章:

  • 绿色简单网站外贸人常用的app
  • 下载源代码建网站网络营销网站规划建设实训作业
  • 关于公司网站建设的请示什么是商业网站
  • 四川省建设厅的注册中心网站企业年金离职后怎么办
  • 广安哪里做网站行业门户网站建设方案
  • 个性化的个人网站简易南昌seo网站管理
  • 淘宝网站建设素材品牌策划 网站源码
  • 吉林整站优化电商品牌推广方案
  • 佛山网站建设公司价格多少做网站用哪几个端口 比较好
  • win7 搭建iss网站wordpress浏览量显示
  • 建设网站的申请信用卡分期付款淘宝店铺首页装修
  • 潍坊定制网站搭建开发网站和电脑软件的区别
  • 网站正在建设中页面 英文wordpress 推送到百度
  • 湛江手机网站制作dede织梦做的网站 栏目页有切换js 怎么循环子栏目 调子栏目
  • 站长统计代码wordpress迁移500
  • 江门制作网站公司导入wordpress
  • 网站分站系管理系统入口admin
  • 网站开发前的准备入侵网站被判多少年
  • 深圳做网站公司排名中国最好的室内设计网
  • 所有外包网站怎么给自己做个网站
  • 电子商务网站开发教程课本例题做外贸网站服务器要选择哪里的
  • 网站怎么做qq微信登陆界面温州商城网站建设
  • 手机app视频制作搜索引擎优化答案
  • 海晏县公司网站建设化妆品网站设计论文
  • dedecms仿站教程广州天河区房价2021最新价格
  • 建设银行官网首页网站公告wordpress怎么变中文版
  • 专门做单页的网站wordpress 主机和域名绑定域名
  • 可以做设计兼职的网站wordpress安卓手机版
  • 3d网站带后台下载网站备案信息是什么意思
  • 高邮做网站宁波海曙网站建设