Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add documentation to custom attributes?

I know how to create custom attributes for views, for example:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="SomeViewsCustomAttrs">
        <attr name="someAttr" format="dimension" />
        <attr name="anotherAttr" format="boolean" />
    </declare-styleable>
</resources>    

I am wondering if there is a way to add documentation to these custom attrs. While editing layouts in the XML editor, you can get tooltips that describe what the attrs are. As an example, if you are typing android:layout_width= it will give you the following information, "Specifies the basic width of the view. [dimension, enum]"

Is there a way to provide that for your own attrs?

Thanks

like image 894
cottonBallPaws Avatar asked Jul 19 '12 17:07

cottonBallPaws


People also ask

How do I add a custom attribute to a file?

Click Add Files. . On the Add Custom Attribute File dialog box, browse to and select the custom attribute files you want to add, and click OK. Drag the custom attribute files from Windows Explorer onto the Custom Attribute Files list.

How do I add custom attributes in react?

To add custom HTML attributes in React, we can just add them as we do with regular HTML element attributes. We just add the custom-attribute custom attribute and it'll be rendered in the HTML. This works since React 16.

How do I add a custom attribute in AD?

To create a new Attribute:Choose File > Add or Remove Snap-ins then select the Active Directory Schema option. Double-click or click Add then click OK to load the Snap-in. Once the Snap-in has been loaded, expand this out, right-click on the Attributes entry then select Create Attribute... to continue.

What are document attributes?

Attributes of a document are the properties of a document or what is contained within the structure of a document. For example, each of your documents might contain title, body text, and author. You can also add your own custom attributes of your documents.


1 Answers

Add XML comment to every element:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="SomeViewsCustomAttrs">
        <!-- Default highlight color for items that are pressed. -->
        <attr name="colorPressedHighlight" format="color" />
        <!-- Default highlight color for items that are long-pressed. -->
        <attr name="colorLongPressedHighlight" format="color" />
    </declare-styleable>
</resources> 

And in the Java Doc in the Java source file of your view link to the attributes like this (example from TextView):

* See {@link android.R.styleable#TextView TextView Attributes}, {@link android.R.styleable#View View Attributes}
like image 61
Ralph Bergmann Avatar answered Oct 02 '22 13:10

Ralph Bergmann