Because you want to use open source androidannotations annotations, you find that eclipse has no annotation processin
Workaround:
Need to configure plugins: Http://download.eclipse.org/releases/juno
Annotation Processin
http://blog.csdn.net/vurtne_ye/article/details/38850529
When Butterknife.jar is added to the project, the annotations are found to be unsuccessful when executing the code. After reviewing the documentation, you find that you need to configure the Butterknife in Eclipse. After running again, the problem is resolved successfully. The logging configuration process is as follows: Configuration process Java Code Collection Code Project-right-select Properties-Check Java C
When Butterknife.jar is added to the project, the annotations are found to be unsuccessful when executing the code.
After reviewing the documentation, you find that you need to configure the Butterknife in Eclipse.
After running again, the problem is resolved successfully.
The logging configuration process is as follows:
Configuration process
Java Code Collection Code
Project
Right-click
Select Properties
--Select Java complier
--Select Annotation processing
--Tick Enable project specific settings (tick, other options are automatically checked)
--Select Factory Path
, tick Enable project specific settings
Click Add JARs
Add Butterknife.jar
Use of Butterknife
Butterknife
Let us rescue from the tedious findViewById
. The following is a straightforward way to use
Activity
Activity { super.oncreate (savedinstancestate); Setcontentview (r.layout.simple _activity); Butterknife.inject (//TODO use "injected" ...}}
Fragment is destroyed when the Butterknife is dropped. Reset (this);
FALSE); Butterknife.inject (return view;}}
Adapter
Public View GetView (int position, view view, ViewGroup parent) {Viewholder holder; if (view! = null) {holder = (Viewholder) view.gettag (); } else {view = Inflater.inflate (R.layout.whatever, parent, false); Holde r = new viewholder (view); View.settag (holder);} holder.name.setText ( " John Doe "); //etc ... return view;} static class viewholder { span class= "annotation" > @InjectView (r.id.title) TextView name; @InjectView (r.id.job_title) TextView jobtitle; public viewholder (view view) {Butterknife.inject (this, view);}}}
VIEW LISTS
@InjectViews ({r.id.first_name, r.id.middle_name, r.id.last_name}) List<edittext> nameviews;
CLICK LISTENER Injection
void Submit () { //TODO submit data to server ...}
@Sayhi (Button button) { button. SetText ("hello!");}
You can also bind multiple control IDs
@OnClick ({r.id.door1, R.id.door2, R.id.door3}) void Pickdoor (Doorview door) { if ( Door.hasprizebehind ()) { Toast.maketext (else {toast.maketext ("Try Again", Length_short). Show ();}}
Injection RESET Destroy
Butterknife. Reset(this);
By default and @InjectView
@OnClick
The found control is not allowed to be empty, otherwise it throws an exception.
can add
@Optional
Allow to empty
@InjectView (r.id.might_not_be_there) TextView mightnotbethere; void onmaybemissingclicked () { //TODO ...}
Http://www.tuicool.com/articles/VRruAfA
Http://www.it165.net/pro/html/201404/12375.html
Android Eclipse does not have annotation processin butterknife configuration in Eclipse