Let's first look at a piece of code:
In Android development Findviewbyid is the most common method used to instantiate the controls on the page, basically every control needs to be called once, to join our page there are 100 need to use, then Findviewbyid will write 100 times, Plus the control variable declaration that is 200 lines of code, the same code repeated calls really no meaning, can not be called, can you just declare a variable on it? Only the unexpected, not do not do. Androidannotations, the sample code is as follows:
To implement such a requirement an input box, click the button, the input box to display the input content:
Package Com.handpay;import Android.app.activity;import Android.widget.button;import android.widget.edittext;import Android.widget.textview;import Com.googlecode.androidannotations.annotations.click;import Com.googlecode.androidannotations.annotations.eactivity;import Com.googlecode.androidannotations.annotations.notitle;import Com.googlecode.androidannotations.annotations.ViewById, @EActivity (r.layout.activity_main) @NoTitlepublic class Mainactivity extends Activity {@ViewById EditText myinput; @ViewById TextView mytextview; @ViewByIdButton MyButton; @Click public void MyButton () {Mytextview.settext (Myinput.gettext (). toString ());} }
This is achieved, haha!!
Accounts of Huaxia Edition set Cheng Zhijia Card reader-androidannotations Frame Association