What is AttributeSet in Android?
How can i use it for my custom view?
You can use AttributeSet to get extra, custom values for your view which you define in the xml. For example. There's a tutorial about Defining Custom Attributes which states, "it's possible to read values from the AttributeSet directly" but it doesn't say how to actually do this. It does warn, however, that if you don't use styled attributes then:
If you want to ignore the whole styled attributes thing and just get the attributes directly:
example.xml
Note there are two lines of xmlns (xmlns = XML namespace), the second is defined as xmlns:custom. Then below that custom:myvalue is defined.
CustomTextView.java
public CustomTextView( Context context, AttributeSet attrs )
{
super( context, attrs );
String sMyValue = attrs.getAttributeValue( "http://www.chooseanything.org", "myvalue" );
// Do something useful with sMyValue
}