猿问
下载APP

Android开发框架androidannotations使用初始怎么解决?

Android开发框架androidannotations使用初始怎么解决


holdtom
浏览 124回答 1
1回答

幕布斯7119047

开发工具android studio1、新建工程2、配置project下的build.gradle,添加如下代码    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'3、配置APP下build.gradleapply plugin: 'android-apt'def AAVersion = '3.3.1'apt "org.androidannotations:androidannotations:$AAVersion"compile "org.androidannotations:androidannotations-api:$AAVersion"3、最后菜单Bulid->make project即可使用AA了举个代码例子,如下1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556package com.gservfocus.testaa; import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.ImageView; import com.gservfocus.testaa.net.RestClient;import com.gservfocus.testaa.net.TokenRestClient; import org.androidannotations.annotations.AfterViews;import org.androidannotations.annotations.Click;import org.androidannotations.annotations.EActivity;import org.androidannotations.annotations.OptionsMenu;import org.androidannotations.annotations.ViewById;import org.androidannotations.annotations.rest.RestService; @EActivity(R.layout.activity_main)@OptionsMenu(R.menu.main_menu)public class MainActivity extends AppCompatActivity {    @RestService    RestClient restClient;    @RestService    TokenRestClient tokenRestClient;     @ViewById(R.id.testImageView)    ImageView testImageView;     @ViewById(R.id.requestBtn)    Button requestBtn;     @ViewById(R.id.resultET)    EditText resultET;     public void onDestroy() {        super.onDestroy();    }     @AfterViews    void afterViews(){        resultET.setText("点击登录哟");     }      @Click({R.id.requestBtn})    void onClick(View view){        switch (view.getId()){            case R.id.requestBtn: {                 OrmDatabaseActivity_.intent(this).start();                break;            }        }    }}
打开App,查看更多内容
随时随地看视频慕课网APP
我要回答