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 XMLAnswer1:
Create your own subclass of
com.ofirbit.MyButton) and then reference it in your layouts (e.g.,
<com.ofirbit.MyButton android:id="..." />). <a href="https://github.com/commonsguy/cwac-colormixer" rel="nofollow">Here is an Android library project and demonstration sub-project</a> showing an implementation of a custom
ColorMixer widget and its use in an application. The details of how to implement one of these can be found in <a href="http://commonsware.com/AdvAndroid" rel="nofollow">some Android books</a>, the <a href="http://developer.android.com/guide/topics/ui/custom-components.html" rel="nofollow">Android documentation</a>, and perhaps elsewhere.