文本框(TextView)

package com.hulefei.android.course.chapter3.textview;

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

public class MainActivity_TextView_3_2 extends Activity {

	/* 声明TextView对象 */
	private TextView textview;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		/* 获得TextView对象 */
		textview = (TextView)this.findViewById(R.id.textview);
		
		String string = "TextView示例, 欢迎使用!";
		
		/* 设置文本的颜色 */
		textview.setTextColor(Color.RED);
		/* 设置字体大小 */
		textview.setTextSize(20);
		/* 设置文字背景 */
		textview.setBackgroundColor(Color.BLUE);
		/* 设置TextView显示的文字 */
		textview.setText(string);
	}
}

猜你喜欢

转载自hulefei29.iteye.com/blog/1806524