Connection between a view in an xml file and an extended View class

Is there a way to associate the inherit class with an XML file.

I am trying to connect an extended class to a widget in an XML file.

Is it possible?

Thanks in advance.

+2
source share
1 answer

, , , , XML-, "" (, TextView, EditView), / (, LinearLayout, RelativeLayout ..). Android , View . XML-.

, , :

public class com.views.MyView extends View{}

XML, :

<LinearLayout ..>
    <com.views.MyView .. />
</LinearLayout>

, View XML , , : . AttributeSet ( , XML).
. this

+1

Source: https://habr.com/ru/post/1726571/


All Articles