你的位置:首页 > 软件开发 > 操作系统 > xUtils如何通过注解对FindViewById进行封装

xUtils如何通过注解对FindViewById进行封装

发布时间:2015-06-04 00:00:20
之前讲到了介绍了一下xUtils的基本使用方法,今天我们就来详细介绍一下关于xUtils中的ViewUtils模块。  在ViewUtils模块中我们首先看到的是它采用了一种注解的方式进行声明,那么我们首先来了解一下什么是注解。  注解(Annotation)很重要,未来的开发模 ...

xUtils如何通过注解对FindViewById进行封装

  之前讲到了介绍了一下xUtils的基本使用方法,今天我们就来详细介绍一下关于xUtils中的ViewUtils模块。

  在ViewUtils模块中我们首先看到的是它采用了一种注解的方式进行声明,那么我们首先来了解一下什么是注解。

  注解(Annotation)很重要,未来的开发模式都是基于注解的,JPA是基于注解的,Spring2.5以上都是基于注解的,Hibernate3.x以后也是基于注解的,现在的Struts2有一部分也是基于注解的了,注解是一种趋势,现在已经有不少的人开始用注解了,注解是JDK1.5之后才有的新特性。

  JDK1.5之后内部提供的三个注解

       @Deprecated 意思是“废弃的,过时的”

       @Override 意思是“重写、覆盖”

       @SuppressWarnings 意思是“压缩警告”

  我们首先来了解一下JDK内部提供的注解中比较难懂的一个SuppressWarnings,这是从jdk1.5的文档中找到的SuppressWarnings的值

all  - suppress all warnings from this code  

deprecation  - suppress warnings from using deprecated code  

unchecked - suppress warnings from an unchecked call or an unchecked cast  

fallthrough - suppress warnings if a switch falls through without finding a valid case (and no default)  

serial - suppress warnings if a Serializable class does not define a serialVersionUID  

finally - suppress warnings from return within a finally (which will ignore return with the try) 

  示例:

·   @SuppressWarnings("unchecked")

告诉编译器忽略 unchecked 警告信息,如使用List,ArrayList等未进行参数化产生的警告信息。

·   @SuppressWarnings("serial")

如果编译器出现这样的警告信息:The serializable class WmailCalendar does not declare a static final serialVersionUID field of type long

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:xUtils如何通过注解对FindViewById进行封装

关键词:ie

ie
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。