excilys/androidannotations — Issue #111: @EViewGroup should be programmatically instantiable 
Author: shuya-inc
Created: 2012-02-16 22:30:34+00:00
State: open

Given the following ViewGroup:

```java
@EViewGroup(R.layout.component)
public class CustomFrameLayout extends FrameLayout {
// This is what Android call when inflated from an XML layout file
public CustomFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
// The user can define as many constructor he wants, and these should be programmatically usable.
public CustomFrameLayout(Context context, int i) {
super(context);
}
...
}
```

Every constructor is copied into the subclass. The following can't work because the implementation behind would'nt be able to know if it should call inflate() or not.

```java
@EActivity(R.layout.main)
public class CustomFrameLayoutActivity extends Activity {
...
CustomFrameLayout layout = new CustomFrameLayout_(this, 2);
...
}
```

But having a static factory method would do:

```java
@EActivity(R.layout.main)
public class CustomFrameLayoutActivity extends Activity {
...
CustomFrameLayout layout = CustomFrameLayout_.getInflatedInstance(this, 2);
...
}
```