AndroidAnnotations框架

xiaoxiao2021-02-28  80

官网 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); }
转载请注明原文地址: https://www.6miu.com/read-56665.html

最新回复(0)