I am building a custom view. I am able to successfully get resources using format="reference"
. However, I now want to pass the id of another view as an attribute and I want following restrictions on that similar to the relative layout.
- This must be id or reference to a view - not drawable or color or any other value.
- the layout with the id that is supplied must exist inside the current XML file.
- I should be able to get a reference to that view and should be able to pass that view to other methods.
For example in relative layout, if you enter layout_below = "@id+/someid"
and if someid
isn't suitable it shows warning or error.
How to achieve this, please help.
Update
This is how i define the attribute
<attr name="myView" format="reference"/>
<attr name="dimen" format="dimension"/>
this is how I define view in layout xml
....
xmlns:custom="http://schemas.android.com/apk/res-auto"
.....
<myPackage.mycustomView android:id = "@+id/myId"
custom:dimen = "10dp" ///-- this one works fine
custom:myView = "@+id/id_of_another_view_in_xml" //-- I am not able to retrive this view
....
/>