"Android Advanced Light"--butterknife

Source: Internet
Author: User

NO1:

Adding dependent libraries

Project's Build.gradle file add

buildscript{...    dependencies{...    Classpath ' com.neenbedankt.gradle.plugins:android-apt:1.8 '}    }

Add the Build.gradle file in Module:app

Apply plugin: ' com.neenbedankt.android-apt ' ... dependencies{...compile ' com.jakewharton:butterknife:8.4.0 ' apt ' Com.jakewharton:butterknife-compiler:8.4.0 '}

No2:

Bound control ID

@BindView (R.id.tv_text) TextView tv_text;

No3:

Binding Resources

@BindString (r.string.app_name) string appName; @BindArray (R.array.swordsman) string[] swordsman; @BindDimen ( R.dimen.activity_horizontal_margin)float margin;

No4:

Binding monitoring

@OnClick (R.id.bt_button1)  Public void showtoast () {} @OnLongClick (R.id.bt_button2)  Public Boolean setText (Button button) {    returntrue;}
 @OnTextChanged (Value=r.id.et_edittext,callback=ontextchanged.callback.before _text_changed)  void  beforetextchanged (charsequence s,int  start,int  count,int   after) {} @OnTextChanged (value  =r.id.et_edittext,callback= OnTextChanged.Callback.TEXT_CHANGED)  void  ontextchanged (charsequence s , int  start,int  before,int   count" {} @OnTextChanged (value  =r.id.et_edittext,callback= ontextchanged.callback.after_text_changed)  void   aftertextchanged (Editable s) {}  
@OnTouch (R.id.bt_button3)  Public Boolean OnTouch (View view,motionevent event) {    returntrue;} @OnItemClick (r.id.lv_list)void onitemclick (int  position) {}

NO5:

Optional bindings

@Nullable @bindview (r.id.tv_toptext) TextView name;

NO6:

Butterknife annotation Processor is butterknifeprocessor, the main processing logic is in the process method

->findandparsetargets

->brewjava

->createbinding

->findbindingconstructorforclass

->findrequiredviewastype

->findrequiredview

->decorview.findviewbyid

->castview

"Android Advanced Light"--butterknife

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.