前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >实习入职第五天:参数中的可变参数等小知识点

实习入职第五天:参数中的可变参数等小知识点

作者头像
wust小吴
发布2019-07-08 18:04:24
5000
发布2019-07-08 18:04:24
举报
文章被收录于专栏:风吹杨柳风吹杨柳

int java.lang.Enum.ordinal()

Returns the position of the enum constant in the declaration. The first constant has an ordinal value of zero.

Returns:

the ordinal value of this enum constant.

java.lang.Enum.ordinal()方法返回此枚举常量的序数(其枚举声明中的位置,其中初始常量分配的序数为零)

msg.sendToTarget():就是把消息发送给handler

  Message msg = handler.obtainMessage();                         msg.arg1 = i;                         msg.sendToTarget(); 

Message msg=new Message();     msg.arg1=i;     handler.sendMessage(msg);

一个是msg直接发送,一个是handler发送

addFooterView()方法:主要是向listView的底部添加布局   添加布局的时候应该添加从父容器开始添加,而不能直接添加父容器中的子控件。例如:从一个xml布局文件中添加一个button控件,   只能将整个布局xml文件添加进去。而不能单单只添加button控件。   当添加头部和底部布局还有另外一个重载方法就是addHeaderView(headView, null, false) 和addFooterView(footerView, null, false)方法。   这个方法与上面的方法区别在于:当给listView设置点击事件的时候,可以控制添加的布局是否可出发点击事件。区别是前一个方法可以控制header是否可以被selected,如果不想被selected则将第三个参数设置成false。 下面以addFooterView()方法为例:   addFooterView()方法必须放在listview.setadapter前面,给listview添加头部必须在绑定adapter前添加,否则会报错。   原因是当我们在调用setAdapter方法时android会判断当前listview是否已经添加header,如果已经添加则会生成一个新的tempadapter,这个新的tempadapter包含我们设置的adapter所有内容以及listview的header和footer。所以当我们在给listview添加了header后在程序中调用listview.getadapter时返回的是tempadapter而不是我们通过setadapter传进去的adapter。如果没有设置adapter则tempadapter与我们自己的adapter是一样的。   listview.getadapter().getcount()方法返回值会比我们预期的要大,原因是添加了header。   我们自定义adapter里面的getitem方法里面返回的position是不包括header的,是我们自定义adapter中数据position编号从0开始,也就是说与我们传进去的list的位置是一样的。 而Activity中listview的onitemclick方法:   public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3)   arg2是当前click的位置,这个位置是指在tempadapter中的位置,从0开始如果listview中添加了header则0代表header。   也就是说当我们在使用点击事件时,listView列中的位置为arg2-1   一般在开发中,为了达到我们想要的动态添加的效果主要的做法是:在listview.setadapter之前添加所需要的控件,然后使用removeFooterView()方法移除控件。   在这里需要注意的是,每对listView的动态操作都要进行一次removeFooterView()方法移除控件。否则listView会自动添加空白行,从而影响显示的效果。

Intent android.content.Intent.setPackage(String packageName)

(Usually optional) Set an explicit application package name that limits the components this Intent will resolve to. If left to the default value of null, all components in all applications will considered. If non-null, the Intent can only match the components in the given application package.

Parameters:packageName The name of the application package to handle the intent, or null to allow any application package.Returns:Returns the same Intent object, for chaining multiple calls into a single statement. 指定 intent由谁执行

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016年05月24日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档