A this point all ok FragmentView created and all views are injected.
public class ViewWithViews extends LinearLayout implements View.OnClickListener {
@InjectView(R.id.child_text)
TextView textView;
private View button;
@Inject
private SharedPreferences sharedPreferences;
public ViewWithViews(Context context) {
super(context);
init();
onFinishInflate();
}
private void init() {
inflate(getContext(), R.layout.child_view, this);
}
public ViewWithViews(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public ViewWithViews(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
@Override
protected void onFinishInflate() {
super.onFinishInflate(); // sharedPreferences are injected!
this.button = findViewById(R.id.button);
this.button.setOnClickListener(this);
RoboGuice.injectMembers(getContext(), this); //force injection
}
@Override
public void onClick(View view) {
System.out.println(view); // all possible events are passed, manual click. "textView" is not injected
}
}