내 프로젝트 AndroidAnnotations 및 Dagger에서 사용하고 있습니다.Android의 다른 클래스에보기 삽입
Dagger를 통해 다른 클래스에보기 (AndroidAnnotations를 통해 활동으로 주입 됨)를 삽입하고 싶습니다.
지금이 코드를 가지고,하지만 난 ActionBarDrawerToggle
@Injection
로 얻을 싶습니다 : 나는 이런 식으로 뭔가를했습니다
// MainActivity.java
@EActivity(R.layout.activity_main)
public class MainActivity extends ActionBarActivity {
@ViewById
DrawerLayout drawerLayout;
ActionBarDrawerToggle mMainDrawerToggle;
@AfterInject
void daggerInject() {
application.inject(this);
}
@AfterViews
void setupViews() {
mMainDrawerToggle = new ActionBarDrawerToggle(
this,
drawerLayout,
R.drawable.ic_main_drawer,
R.string.main_drawer_open,
R.string.main_drawer_close);
}
}
하지만 단검을 얻는 방법을 모르기 때문에 작동하지 않습니다 DrawerLayout 객체입니다.
// ApplicationModule.java
@Module(
library = true,
injects = MainActivity_.class
)
public class ApplicationModule {
private final MyApp application;
public ApplicationModule(MyApp application) {
this.application = application;
}
@Provides
ActionBarDrawerToggle provideActionBarDrawerToggle(DrawerLayout drawerLayout) {
return new ActionBarDrawerToggle(
application,
drawerLayout,
R.drawable.ic_main_drawer,
R.string.main_drawer_open,
R.string.main_drawer_close);
}
}
내가
ActionBarDrawerToggle
이 단검으로 주입 될 것으로 만들 수있는 방법
?