package com.example.layout03;

import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);

	    // display
	    setContentView(R.layout.activity_main);

	    Context mContext = getApplicationContext();
	    LinearLayout mainLayout = (LinearLayout) findViewById(R.id.regions_search);
	    // Create a new LinearLayout
	    LinearLayout newLinear = new LinearLayout(mContext);
	    newLinear.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

	    // create a new Button
	    Button test = new Button(mContext);
	    test.setText("My button");

	    // first , I add button to the LinearLayout
	    newLinear.addView(test);

	    // Then, I add layout to the inflated layout
	    mainLayout.addView(newLinear);
	}

	
}
