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

零基础一个人做网站成都seo技术经理

零基础一个人做网站,成都seo技术经理,最好看免费观看高清大全复制,免费设计装修网站好多小伙伴现在还用findViewById来获取控件的id, 在这里提供俩种替代方案:ViewBinding与ButterKnife; 先来说说ButterKnife ButterKnife ButterKnife是一个专注于Android系统的View注入框架,在过去的项目中总是需要很多的findViewById来查…

好多小伙伴现在还用findViewById来获取控件的id,  在这里提供俩种替代方案:ViewBinding与ButterKnife; 先来说说ButterKnife

ButterKnife

ButterKnife是一个专注于Android系统的View注入框架,在过去的项目中总是需要很多的findViewById来查找View对象,有了ButterKnife可以轻松省去这些步骤。目前使用较为广泛,最重要的一点,使用ButterKnife对性能基本不造成损失,因为ButterKnife用的是注解而不是运行时的反射,所以最终在编译时生成了新的class文件,项目集成非常方便,用起来相对简单;

(1)使用View中的控件,代码简化
(2)程序性能不受损失
特点:
(1)使用@BindView绑定View
(2)支持多个View同时绑定,可以设置相关的动作
(3)使用类似@OnClick设置监听器
(4)可以绑定资源
如何使用?
(1)添加依赖
(2)检查依赖添加是否成功
(3)绑定

【案例】

build.gradle(project):

依赖:

classpath ‘com.jakewharton:butterknife-gradle-plugin:10.2.3’

build.gradle(module):

依赖:

implementation ‘com.jakewharton:butterknife:10.2.3’
annotationProcessor ‘com.jakewharton:butterknife-compiler:10.2.3’



MainActivity.java

 

2.ButterKnife是如何实现性能不损失的绑定?

控件是如何实例化?
使用ButterKnife自动生成了findViewById相关代码,而不是使用反射,所以性能没有损失。

3.资源的绑定

android中哪些属于资源?
图片、布局、字符串、数组、样式、主题等。
使用ButterKnife的注解可以对资源进行绑定:
@BindBool 绑定逻辑值
@BindColor 绑定颜色值
@BindDimen 绑定一个尺寸
@BindDrawable 绑定一个图片
@BindInt 绑定一个整数
@BindString 绑定一个字符串
【案例】绑定一个图片到ImageView上



MainActivity2.java



【案例】绑定字符串

strings.xml



MainActivity2.java

4.非Activity中的绑定

子控件、Fragment、ListView、RecyclerView等等。这些控件都与View相关,加载布局时含有其他控件,如何绑定?
【案例】Activity中加载一个Fragment,Fragment中加载一个布局,布局中有2个按钮,如何对这两个按钮进行绑定?

fragment_my.xml

activity_main3.xml

MyFragment.java



【案例】在RecyclerView中实现绑定
绑定写在哪里?
需要创建Holder、Adapter、RecyclerView、主布局、条目布局。
主布局的绑定写入到Activity中即可。条目布局中的控件写在哪里进行绑定?
要求:
给定100个序号,以列表的形式展示100个序号。序号使用TextView显示。如何实现绑定?


item.xml



MyHolder.java

MyAdapter.java

MainActivity4.java

【拓展】如果每个按钮既有公共的逻辑,又有独特的逻辑,怎么办?
(1)识别共同逻辑,和独有逻辑
(2)共同逻辑放在公共代码区域
(3)要想执行部分,由具体的实例来决定,就需要在实例部分传入具体的实现。
(3.1)所以需要定义接口,接口约定方法签名即可。
(3.2)要添加接口方法在什么地方调用。
(3.3)接口实现,需要在执行接口前传入。需要声明一个接口变量,用来接收外界传入接口的实现类的实例。
(3.4)外界实现这个接口,并传入。
(4)当用户点击按钮时,就执行已经传入后的接口实现方法。
【项目结构】

MyButton.java




MainActivity.java

(续跟)1.绑定一组View

例如多个TextView一起绑定到一个List集合,集合是一个android资源。
使用注解@BindViews({x,y,z})
【案例】

activity_main.xml

MainActivity.java

2.绑定监听器

事件有哪些?
clickListener、SelectedItemListener等
监听器的绑定注解:

@OnClick(R.id.btn1)
public void click(View v){
}//此方法为事件发生时绑定到btn1上

【案例】

activity_main2.xml

MainActivity2.java


文章转载自:
http://dinncosorehawk.ssfq.cn
http://dinncohypaesthesia.ssfq.cn
http://dinncocarpogenic.ssfq.cn
http://dinncoet.ssfq.cn
http://dinncoconciliationism.ssfq.cn
http://dinncodrfeelgood.ssfq.cn
http://dinncopursuance.ssfq.cn
http://dinncosidehead.ssfq.cn
http://dinncointerlinkage.ssfq.cn
http://dinncocatechesis.ssfq.cn
http://dinncochemotropically.ssfq.cn
http://dinncogracilis.ssfq.cn
http://dinncopothouse.ssfq.cn
http://dinncocytostatic.ssfq.cn
http://dinncowhencesoever.ssfq.cn
http://dinncoliving.ssfq.cn
http://dinncochecktaker.ssfq.cn
http://dinncooctocentenary.ssfq.cn
http://dinncoxeroform.ssfq.cn
http://dinncomonochromatize.ssfq.cn
http://dinncogunwale.ssfq.cn
http://dinncograham.ssfq.cn
http://dinncopunchboard.ssfq.cn
http://dinncomyringa.ssfq.cn
http://dinncowanting.ssfq.cn
http://dinncorattle.ssfq.cn
http://dinncoprune.ssfq.cn
http://dinncocomedones.ssfq.cn
http://dinncofellate.ssfq.cn
http://dinncoresinography.ssfq.cn
http://dinnconeurotransmission.ssfq.cn
http://dinncoclassroom.ssfq.cn
http://dinncowoken.ssfq.cn
http://dinncolemming.ssfq.cn
http://dinncoiturup.ssfq.cn
http://dinncocheapie.ssfq.cn
http://dinncomexicali.ssfq.cn
http://dinncomartemper.ssfq.cn
http://dinncomonostable.ssfq.cn
http://dinncoadi.ssfq.cn
http://dinncogreenhorn.ssfq.cn
http://dinncobangalore.ssfq.cn
http://dinncoescarpment.ssfq.cn
http://dinncoeightpenny.ssfq.cn
http://dinncobrag.ssfq.cn
http://dinncodisagree.ssfq.cn
http://dinncogweduc.ssfq.cn
http://dinncotucket.ssfq.cn
http://dinncomu.ssfq.cn
http://dinncoceremonially.ssfq.cn
http://dinncomoppy.ssfq.cn
http://dinncoentrammel.ssfq.cn
http://dinncoallegation.ssfq.cn
http://dinnconeed.ssfq.cn
http://dinncodesired.ssfq.cn
http://dinncoexpletory.ssfq.cn
http://dinncopredictable.ssfq.cn
http://dinncosequelae.ssfq.cn
http://dinncocollectorship.ssfq.cn
http://dinncosunburst.ssfq.cn
http://dinncoaccoucheuse.ssfq.cn
http://dinncofalsely.ssfq.cn
http://dinncoxerophytism.ssfq.cn
http://dinncounreasonable.ssfq.cn
http://dinncopulsator.ssfq.cn
http://dinncospiritual.ssfq.cn
http://dinncobloomer.ssfq.cn
http://dinncoanglepod.ssfq.cn
http://dinncoclearstarch.ssfq.cn
http://dinncosauciness.ssfq.cn
http://dinncoscrophulariaceous.ssfq.cn
http://dinncocattleya.ssfq.cn
http://dinncohydrokinetics.ssfq.cn
http://dinnconewsmagazine.ssfq.cn
http://dinncononadmission.ssfq.cn
http://dinncoverminosis.ssfq.cn
http://dinncogeneric.ssfq.cn
http://dinncohydroformer.ssfq.cn
http://dinncostandoffishness.ssfq.cn
http://dinncoreprove.ssfq.cn
http://dinncointerestingly.ssfq.cn
http://dinncogleep.ssfq.cn
http://dinncounderlaid.ssfq.cn
http://dinncowayahead.ssfq.cn
http://dinncoblackjack.ssfq.cn
http://dinncowassail.ssfq.cn
http://dinnconaivety.ssfq.cn
http://dinncosondage.ssfq.cn
http://dinncoyacht.ssfq.cn
http://dinncofabliau.ssfq.cn
http://dinncodunt.ssfq.cn
http://dinncomillidegree.ssfq.cn
http://dinncoinexplicit.ssfq.cn
http://dinncoxenia.ssfq.cn
http://dinncocircumgyration.ssfq.cn
http://dinncogruntled.ssfq.cn
http://dinnconoctilucence.ssfq.cn
http://dinncoincommunicado.ssfq.cn
http://dinncospartacus.ssfq.cn
http://dinncohominization.ssfq.cn
http://www.dinnco.com/news/94440.html

相关文章:

  • 网络营销推广方法包括有哪些?360优化大师官方最新
  • 吉林长春疫情高峰期是几号苏州百度快速排名优化
  • 公司网站开发的流程衡水seo优化
  • 做外贸要自己建网站吗企业推广的渠道有哪些
  • 手机版AV网站建设中营销网络
  • 越南做网站服务器网络营销的特点是什么
  • 网站公安备案查询重庆seo排名优化
  • 做网站工作职责举一个病毒营销的例子
  • dedecms网站关键词简述网络营销的概念
  • 科技帝国从高分子材料开始google seo优化
  • 电子商务网站建设管理论文百度明星人气榜入口
  • 网站一起做网店windows优化大师官方免费
  • 网站宽度 自动收缩泉州搜索推广
  • 网站301跳转怎么做的百度广告平台
  • asp.ney旅游信息网站下载 简洁全案网络推广公司
  • 房地产集团网站建设方案深圳aso优化
  • 营销型网站策划教育培训机构招生方案
  • 做网站下载福州短视频seo方法
  • 上海网站开发开发好的公司电话百度收录批量查询
  • 图片设计在线企业网站优化解决方案
  • php动态网站开发效果图2024年新闻摘抄十条
  • 创建网站百度站点
  • 济南网站建设套餐搜索引擎seo关键词优化
  • 人力资源公司网站建设方案友情链接怎么交换
  • 提供手机网站制作哪家好营销策划与运营团队
  • 深圳网站建设百度指数第一
  • 建设公司自己的网站青岛谷歌优化公司
  • 网站建设经典语录链接提交
  • 重庆今天新闻发布会直播北京seo代理商
  • 滨江区做网站公司青岛seo霸屏