I want to make a custom view by extending View class. then I defined all three constructor.(below my custom view code)
public class CustomButton extends Button
{
public CustomButton(Context context)
{
super(context);
}
public CustomButton(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public CustomButton(Context context, AttributeSet attrs, int defStyleAttr)
{
super(context, attrs, R.attr.testStyle);
}
}
Xml Code :
<com.example.viewlifecycledemo.CustomButton
style="@style/test"
android:layout_width="100dp"
android:layout_height="100dp" />
Only ViewLifeCycleClass(Context context, AttributeSet attrs)
is called, but I applied style, so ViewLifeCycleClass(Context context, AttributeSet attrs, int defStyleAttr)
this method should be get call.
can anybody tell me, why two parametrized called?
This link is not working for me : Android Custom View Constructor