package com.example.tutorial;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
* Created by Shiburagi on 26-Jan-15.
*/
public class MainLayout extends RelativeLayout{
/**
* Constructor
* @param context
*/
public MainLayout(Context context) {
super(context);
// call init function
init(context);
}
public MainLayout(Context context, LayoutInflater inflater){
super(context);
// call init function
init(context);
// call and receive view from the activity_main.xml
View view = inflater.inflate(R.layout.activity_main, null);
// add the view into layout
addView(view);
}
/**
* to initialize component been used in the application
* @param context
*/
private void init(Context context ){
// declare textview component
TextView textView=new TextView(context);
// set value of the textview.
textView.setText("Hello World!");
// add textview into this layout
addView(textView);
}
}