Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

@EViewGroup and @EView should be programmatically instantiable  #111

@JoanZapata

Description

@JoanZapata

Given the following ViewGroup:

@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.

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

But having a static factory method would do:

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions