I want to create a set of objects which inherit from some Android View objects. For exemple, I want to create a custom button (which I may call CustomButton) inheriting from Button.
CustomButton has several parameters which Button doesn’t have, let’s say it contains an int called “start_count”, and that a custom methods shows start_count+(the number of press actions).
A Button object is nearly always created using an XML layout.
I’d like to create my CustomButton exactly the same way, with another attribute called for exemple : android:startCount=”3″.
I don’t really know where to search. Do you happen to have a useful link or advice about this problem ?
You can just extend your class
CustomButtonfrom the Button class, and add to it whatever you want.see this. You can like change text, functions, or drawables etc with for example
this.setText(), ormButton.setText()(after CustomButton mButton = new… ofcourse)