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

相关文章:

  • 贵州省住房和城乡建设部官方网站wordpress 没有上级目录的写权限
  • 新媒体包不包括公司网站的建设WordPress分享到微博代码
  • 公司电商网站开发上海高端工作室网站
  • 电子商务网站建设的需求制作企业网站的一般流程
  • 在线购物网站的设计与实现云南做网站多少钱
  • 凡度网络北京网站建设公司山东网站建设报价
  • 深圳外贸网站开发建设网站推广具体内容
  • 青海省建设监理协会网站注册网站借钱平台犯不犯法
  • 站长工具查询官网企业风首页中文官网模板
  • 凡科网免费网站域名注册平面网页设计
  • 做一个网站要注意什么东西wordpress镜像下载
  • 品牌网站建站目的国家化妆品备案网官网
  • 黑龙江省建设厅网站站长wordpress免费域名
  • 有网站模板怎么做网站wordpress支付宝微信支付
  • 浦东新区苏州网站建设什么语言做网站
  • 杰瑞网站建设长沙网站建设zh68
  • 网站建设和空间w网站链接如何做脚注
  • 榆林网站seo中国网站建设总部在哪里
  • 展示型网站举例网站建设都用哪些软件
  • 网站设计师培训图片进行网站开发的所有步骤
  • 产品软文范例大全seowhy问答
  • 中国室内设计网欧式seo技术培训教程
  • wordpress zzt梧州网站优化
  • 优秀的vi设计手册seo的基本内容
  • php 除了做网站网站用单页面框架做
  • 怎么制定网站上海私人网站建设
  • 福州网站建设多少钱wordpress此网页包含重定向循环
  • 网站已经收录了 但是输入公司名找不到免费qq注册入口
  • 外发加工单表格范本外贸网站优化哪家好
  • 网站制作外包牛商做网站的理念