dcanh121
dcanh121

Reputation: 4695

Android Butterknife create and inject views dynamically

public class Class1View extends LinearLayout{

   @Override
   protected void onFinishInflate(){
     super.onFinishInflate();    
     Butterknife.bind(this);    
   }   
}

How do I create a new view, for example, a new Button() and add it to this Class1View

I tried,

Butterknife.bind(this, new Button(getContext());

but it does not work.

Upvotes: 0

Views: 627

Answers (1)

fluffyBatman
fluffyBatman

Reputation: 6704

As per my understanding, Butterknife is there to help you bind a View element which is declared somewhere in XML. Since you're extending a View and want to add more Views within it dynamically, butterknife here is no use.

Upvotes: 1

Related Questions