Android: override onDraw without subclassing when View has been instantiated from xml -


i have class conditionaledittext compound custom view containing edittext , textview. layout of view defined in xml. want override ondraw method of edittext. since has been instantiated xml. cannot like

edittext edt = new edittext() {     protected void ondraw() {         ....     } } 

is there way override ondraw() method other sublclassing edittext or doing ui instantiation java rather xml?

you should override edittext , instantiate own custom edittext in xml :

public class customedittext extends edittext {     public customedittext(context context, attributeset attrs) {         super(context, attrs);     }      public void ondraw() {         // code     } } 

for xml instantiation :

<com.android.example.customedittext     ... /> 

for more information, see official documentation : http://developer.android.com/guide/topics/ui/custom-components.html#modifying


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -