I want to create my own custom controls in Android application and use them in this way: In the XML file:
<MyButton .... />
I would like to define MyButton some where in the resources XML
I want to create my own custom controls in Android application and use them in this way: In the XML file:
<MyButton .... />
I would like to define MyButton some where in the resources XML
Create your own subclass of
View
(e.g.,com.ofirbit.MyButton
) and then reference it in your layouts (e.g.,<com.ofirbit.MyButton android:id="..." />
). Here is an Android library project and demonstration sub-project showing an implementation of a customColorMixer
widget and its use in an application. The details of how to implement one of these can be found in some Android books, the Android documentation, and perhaps elsewhere.