package com.example.eg16_1;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.Menu;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MainActivity extends Activity {
	
	LinearLayout linearLayout;
	LinearLayout.LayoutParams param;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		//动态创建textView
		linearLayout = (LinearLayout)findViewById(R.id.linearLayout01);
		param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
		LinearLayout.LayoutParams.WRAP_CONTENT);
		LinearLayout layout1 = new LinearLayout(this);
		layout1.setOrientation(LinearLayout.HORIZONTAL);
		TextView tv = new TextView(this); 
		tv.setId(200);
		tv.setText("动态创建TextView");
		tv.setBackgroundColor(Color.GREEN);
		tv.setTextColor(Color.RED);
		tv.setTextSize(20);
		layout1.addView(tv, param);
		linearLayout.addView(layout1, param);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
