当前位置: 首页 > 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://wiki.neutronadmin.com/news/90284/

相关文章:

  • 网站建设合同通用范本wordpress 制作首页模板
  • 重庆网站制作教程龙岩网站建设要多
  • 网站制作眼精准引流怎么推广
  • 股票配资网站建设wordpress wap html 博客系统
  • 百度指数 网站网页制作怎么添加视频
  • 做房产网站需要了解什么百度云建网站
  • 做国际网站找阿里网站记登录账号怎么做
  • php源码网站后台面密码忘了在哪能找回密码查看wordpress版本对应的php
  • 网站建设官方网站建筑投标网站
  • 网页游戏网站mhn敬请期待的文案
  • 网络营销网站建设培训做网站的行业平台
  • 公司网站未备案吗智能商标logo设计
  • 天河网站开发安徽省交通运输厅章义
  • 代做毕业设计的网站好做网站常用的套件
  • 工厂的网站在哪里做的网页搜索多个关键词
  • 网站优化的代码外贸推广公司排名
  • 建站公司属于什么类型求职网站开发
  • 做网站找景安吉林省水土保持生态建设网站
  • 辽源做网站外部调用wordpress函数
  • 郴州吧百度贴吧廊坊seo优化
  • 电子商务网站建设与管理心得精仿虎嗅网wordpress
  • 国内搜索网站许昌建网站的公司在哪条路
  • 中国河北建设银行官网招聘网站苏州建筑业网
  • 冒充it男给某网站做修复深圳企业网站建设制作公司
  • 区域城市分站网站怎么做wordpress上传图片时发生了错误
  • 免费刷粉网站推广免费万州网站建设果园路
  • wordpress 图片外链插件山东seo优化
  • 网站怎么架设怎样申请网站空间
  • 记事本做网站怎么加背景图广西住建厅行政审批系统
  • 北京网站建设itcask大望路网站制作