java - Access custom xml value on override method in a extended class -


i extend button class, in class, override method setcompounddrawables shrink drawable button size. set custom value xml element , need access calculate size give drawable. typical stuff typedarray retrieve value, after super call in constructor, when app call setcompounddrawables app has not read custom xml values yet, same (default) value custom variable.

some code:

public mybutton(context context, attributeset attrs, int defstyleattr) {     super(context, attrs, defstyleattr);     this.context = context;     init(attrs); }   public void init(attributeset attrs) {     myvalue = true;     if (attrs != null) {         typedarray = context.gettheme().obtainstyledattributes(                 attrs,                 r.styleable.mybutton,                 0, 0);         try {             myvalue = a.getboolean(r.styleable.mybutton_myvalue, true);         } {             a.recycle();         }     }     log.d(tag, "myvalue (init) = "+myvalue); }  @override public void setcompounddrawables(drawable left, drawable top, drawable right, drawable bottom) {     log.d(tag, "myvalue (setcomp...) = "+myvalue);     ...     super.setcompounddrawables(left, top, right, bottom); } 

when run app printings in order:

myvalue (setcomp...) = false myvalue (init) = true 

can me?

thanks


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -