AndroidAnnotations框架

官网
https://github.com/androidannotations/androidannotations
如何配置环境

视频教程http://www.imooc.com/video/8305

下载jar包,添加依赖
@EActivity(R.layout.translate) // Sets content view to R.layout.translate
public class TranslateActivity extends Activity {

@ViewById // Injects R.id.textInput
EditText textInput;

@ViewById(R.id.myTextView) // Injects R.id.myTextView
TextView result;

@AnimationRes // Injects android.R.anim.fade_in
Animation fadeIn;

@Click // When R.id.doTranslate button is clicked 
void doTranslate() {
     translateInBackground(textInput.getText().toString());
}

@Background // Executed in a background thread
void translateInBackground(String textToTranslate) {
     String translatedText = callGoogleTranslate(textToTranslate);
     showResult(translatedText);
}

@UiThread // Executed in the ui thread
void showResult(String translatedText) {
     result.setText(translatedText);
     result.startAnimation(fadeIn);
}

猜你喜欢

转载自blog.csdn.net/qq_32890771/article/details/76781171