hi guys.
Is there a way to link inherit class to xml file.
I am trying to connect extended class to widget in the xml file.
Is it possible ?
Thanks in advance.
hi guys.
Is there a way to link inherit class to xml file.
I am trying to connect extended class to widget in the xml file.
Is it possible ?
Thanks in advance.
You must have noticed that all the nodes that we specify in the layout XMLs are actually either View classes(for e.g: TextView, EditView) or view containers/layout managers(e.g: LinearLayout, RelativeLayout etc.). Android allows you to create custom views and containers by extending the View class and one of the layout managers, respectively. You can then choose to inflate such views directly from code or specify them as nodes in your layout XMLs.
For instance, assuming you create a View class such as:
public class com.views.MyView extends View{}
then you can include this class directly in you layout XML by saying:
<LinearLayout ..>
<com.views.MyView .. />
</LinearLayout>
Note that when you specify your View class directly in XML there are a few important subtleties to consider such as:
When inflating the custom view, the framework will call different constructor of the view. The arguments would be a context object and AttributeSet(containing attributes you set in the XML).
For more details refer this