27.02.2014 Views

Android 开发教程

Android 开发教程

Android 开发教程

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

-----------------------------------<strong>Android</strong> 编 程 基 础<br />

}<br />

super.onCreate(savedInstanceState);<br />

/* 实 例 化 一 个 LinearLayout 布 局 对 象 */<br />

myLayout = new LinearLayout(this<br />

this);<br />

/* 设 置 LinearLayout 的 布 局 为 垂 直 布 局 */<br />

myLayout.setOrientation(LinearLayout.VERTICAL);<br />

/* 设 置 LinearLayout 布 局 背 景 图 片 */<br />

myLayout.setBackgroundResource(R.drawable.back);<br />

/* 加 载 主 屏 布 局 */<br />

setContentView(myLayout);<br />

/* 实 例 化 一 个 LinearLayout 布 局 参 数 , 用 来 添 加 View */<br />

layoutP = new LinearLayout.LayoutParams(WC, WC);<br />

/* 构 造 实 例 化 TextView 对 象 */<br />

constructTextView();<br />

/* 把 TextView 添 加 到 LinearLayout 布 局 中 */<br />

addTextView();<br />

/* 设 置 TextView 文 本 颜 色 */<br />

setTextViewColor();<br />

/* 设 置 TextView 文 本 内 容 */<br />

setTextViewText();<br />

/* 设 置 TextView 文 本 内 容 */<br />

public void setTextViewText() {<br />

}<br />

black_TV.setText(" 黑 色 ");<br />

blue_TV.setText(" 蓝 色 ");<br />

cyan_TV.setText(" 青 绿 色 ");<br />

dkgray_TV.setText(" 灰 黑 色 ");<br />

gray_TV.setText(" 灰 色 ");<br />

green_TV.setText(" 绿 色 ");<br />

ltgray_TV.setText(" 浅 灰 色 ");<br />

magenta_TV.setText(" 红 紫 色 ");<br />

red_TV.setText(" 红 色 ");<br />

transparent_TV.setText(" 透 明 ");<br />

white_TV.setText(" 白 色 ");<br />

yellow_TV.setText(" 黄 色 ");<br />

/* 设 置 TextView 文 本 颜 色 */<br />

public void setTextViewColor() {<br />

black_TV.setTextColor(Color.BLACK);<br />

blue_TV.setTextColor(Color.BLUE);<br />

dkgray_TV.setTextColor(Color.DKGRAY);<br />

gray_TV.setTextColor(Color.GRAY);<br />

green_TV.setTextColor(Color.GREEN);<br />

ltgray_TV.setTextColor(Color.LTGRAY);<br />

magenta_TV.setTextColor(Color.MAGENTA);<br />

4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!