Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package com.example.tutorial;
  2.  
  3. import android.content.Context;
  4. import android.widget.RelativeLayout;
  5. import android.widget.TextView;
  6.  
  7. /**
  8.  * Created by Shiburagi on 26-Jan-15.
  9.  */
  10. public class MainLayout extends RelativeLayout{
  11.  
  12.     /**
  13.      * Constructor
  14.      * @param context
  15.      */
  16.     public MainLayout(Context context) {
  17.         super(context);
  18.  
  19.         //call init function
  20.         init(context);
  21.     }
  22.  
  23.     /**
  24.      * to initialize component been used in the application
  25.      * @param context
  26.      */
  27.     private void init(Context context){
  28.  
  29.         // declare textview component
  30.         TextView textView=new TextView(context);
  31.  
  32.         // set value of the textview.
  33.         textView.setText("Hello World!");
  34.  
  35.         // add textview into this layout
  36.         addView(textView);
  37.  
  38.     }
  39. }