Suppose I have an xml definition for a button with id like @+id/send_button
How can I get this id attribute value in Java code? I tried the getXXX methods in the AttributeSet class, but does not provide any value that send_button has.
Edit1:
Let me make this a little clearer.
I am creating a custom component View , and I want to know that the id value that the user of this component provided in the XML file.
Edit2:
I do not use custom attributes for a specific reason, but using
<mycomponent android:id="@+id/my_id"/>
Edit 3:
AttributeSet has a getIdAttribute() method, but it just doesn't work. Does anyone know the reason?
source share