简易计算器之ButterKnife应用
来源:互联网 发布:js style.color 编辑:程序博客网 时间:2024/06/04 20:05
引言
自制一个简易的计算器,怎奈按钮过多,需要添加大量的监听。怎么办?ButterKnife前来报道。
ButterKnife的Github地址:https://github.com/JakeWharton/butterknife
ButterKnife的注入
添加依赖
Configure your project-level build.gradle to include the ‘android-apt’ plugin:
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' }}
Then, apply the ‘android-apt’ plugin in your module-level build.gradle and add the Butter Knife dependencies:
apply plugin: 'android-apt'android { ...}dependencies { compile 'com.jakewharton:butterknife:8.4.0' apt 'com.jakewharton:butterknife-compiler:8.4.0'}
Activity注入
@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this);}
Fragment注入
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.keybord_normal_fragment, container, false); ButterKnife.bind(this, view); return view;}
ViewHolder注入
static class ViewHolder {@Bind(R.id.name) TextView name;@Bind(R.id.password) TextView pwd; public ViewHolder(View view) { ButterKnife.bind(this, view); }}
其余绑定
//资源绑定:@BindColor(R.color.red) int red; //控件绑定:@BindView(R.id.home_show_content_tv) TextView mTvShowContent;onClick事件绑定:@OnClick({R.id.cal_num_1_btn, R.id.cal_num_2_btn})public void click(View view){...}
相关参考资料:
http://blog.csdn.net/i374711088/article/details/49102003
0 0
- 简易计算器之ButterKnife应用
- 简易计算器之Stack应用
- Android应用---简易计算器
- Qt之简易计算器
- JAVA之简易计算器
- js之简易计算器
- 栈的应用之简易计算器的实现
- 栈的应用之简易逆波兰计算器
- GO demo之简易计算器
- Android初识之简易计算器
- 简易计算器之换主题
- 计算器之C++简易实现
- 简易计算器(栈的应用)
- 简易计算器设计中的一个数据结构问题——Ada应用实例之二
- 栈应用之简易计算器算法的原理及实现(C语言)
- 蜗牛—JQuery学习之简易计算器
- 蜗牛—JavaScript学习之简易计算器
- JAVA学习笔记---简易计算器之图形界面
- python if语句用法解析
- 6-简单选择结构B
- storm批处理事物原理
- Unity的UGUI中使用ETC1+Alpha的格式
- oslo.config组件初探
- 简易计算器之ButterKnife应用
- Hadoop学习笔记—20.网站日志分析项目案例
- 53. Maximum Subarray
- ubuntu如何调整桌面图标位置
- 后台往前台传值,出现中文乱码问题。
- Navicat11全系列激活(注册机)
- 第十一节上篇:eclipse配置(个人总结)
- top 命令使用详解
- 单链表的建立(头部延长、尾部延长)、插入操作、删除操作(无头结点的删除、有头结点的删除)