AndroidAnnotations 使用教程

2019-02-13  本文已影响0人  NullPoint3Exce

1.简介

2.依赖
module的build.gradle

  annotationProcessor "org.androidannotations:androidannotations:4.5.0"
  implementation "org.androidannotations:androidannotations-api:4.5.0"

3.清单文件里activity的后缀,然后编译。


 <activity android:name=".MainActivity_"> //activity添加后缀下划线
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

4.@EActivity(R.layout.activity_main)

setContentView(R.layout.activity_main);
//改为:
@EActivity(R.layout.activity_main)

  1. @ViewById(R.id.click)
    Button clickBtn;
@ViewById(R.id.click)
 
// 替换
findViewById(R.id.click);

6

   @Click(R.id.click)
    public void btnClick(){

        resultTv.setText("hhhhhhhh");
        Log.d(TAG, "btnClick: ");
    }
    @LongClick(R.id.click)
    public void OnLongClick(){
        resultTv.setText("fffffffffffff");
        Log.d(TAG, "OnLongClick: ");
    }
上一篇下一篇

猜你喜欢

热点阅读