码迷,mamicode.com
首页 > 其他好文 > 详细

ButterKnife 原理

时间:2016-09-22 08:47:00      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

在含有ButterKnife工程中你会 ButterKnife会帮你生成一些类似$ViewBinder文件 文件用反编译工具打开你会看到如下代码:

public class ExampleActivity$$ViewBinder<T extends 
        io.bxbxbai.samples.ui.ExampleActivity> implements ViewBinder<T> {

     @Override public void bind(final Finder finder, final T target, Object source) {
          View view;
          view = finder.findRequiredView(source, 21313618, “field ‘user’”);
          target.username = finder.castView(view, 21313618, “field ‘user’”);
          view = finder.findRequiredView(source, 21313618, “field ‘pass’”);
          target.password = finder.castView(view, 21313618, “field ‘pass’”);
          view = finder.findRequiredView(source, 21313618, “field ‘submit’ and method ‘submit’”);
          view.setOnClickListener(
            new butterknife.internal.DebouncingOnClickListener() {
               @Override public void doClick(android.view.View p0) {
      target.submit();
           }
        });
      }
技术分享

ButterKnife 原理

标签:

原文地址:http://www.cnblogs.com/cfbaoshijie/p/5894852.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!