继承 Android 注释

Inheriting in Android Annotations

我在使用 AndroidAnnotations 时从基础 class 继承时遇到问题。我有一个名为 BaseActivity:

的基 Activity
@EActivity
public abstract class BaseActivity extends AppCompatActivity {

    @ViewById
    Toolbar toolbar;

    @ViewById(R.id.drawer_layout)
    DrawerLayout drawerLayout;

    @ViewById(R.id.nav_view)
    NavigationView navView;
}

我还有一个名为 MainActivity:

的 child activity
@EActivity(R.layout.activity_main)
public class MainActivity extends BaseActivity {

    @ViewById
    ImageButton btnTabHome;
}

当我构建项目时出现以下错误:

****MyProjectBuildPath****\MainActivity_.java
Error:(82, 13) error: toolbar is not public in BaseActivity; cannot be accessed from outside package

Error:(83, 13) error: drawerLayout is not public in BaseActivity; cannot be accessed from outside package

Error:(84, 13) error: navView is not public in BaseActivity; cannot be accessed from outside package

Error:(90, 9) error: cannot find symbol method initBaseViews()

如果我继承自 BaseActivity_,会出现以下错误:

****MyProjectBuildPath****\MainActivity.java
Error:(19, 35) error: cannot find symbol class BaseActivity_

Error:(17, 1) error: org.androidannotations.annotations.EActivity can only be used on an element that extends android.app.Activity

Warning:(19, 8) Element packagename.MainActivity invalidated by EActivityHandler

我的错误在哪里?

关于 androidannotations issues page 我应该只更改字段的修饰符。