As I look further into the android SDK, it keeps amazing more and more. One of the key features of android is “Component(nized) Architecture”, i.e., your whole application is developed as a component, one of the key reasons why you don’t find the age old “public static void main” of the Java platform here.

Same philosophy is also applicable to android UI development, where you can easily develop a UI component as XML and use it as many times as you want, just by a simply inclusion of your component into your main Activity XML.

I developed a very basic code within a few mins. and was thrilled to see the output.

I decided to combine the existing analog clock and the date picker to create a component of my own, and ,got this,

If main.xml is your main activity xml, then the code snippet to “include” a custom component looks like…..

<include android:id=”@+id/cell1″ layout=”@layout/clock_layout” />

Here, clock_layout is the name of your custom component xml(which uses mostly Relative layout techniques) which lies in the layout folder of my android project.

Pretty neat and very simple.

Advertisements