预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共18页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

-----------------------------------Android编程基础 Android基础UI编程1 更改与显示文字标签 TextView标签的使用 导入TextView包 importandroid.widget.TextView; 在mainActivity.java中声明一个TextView privateTextViewmTextView01; 在main.xml中定义一个TextView <TextViewandroid:text="TextView01" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="61px" android:layout_y="69px"> </TextView> 利用findViewById()方法获取main.xml中的TextView mTextView01=(TextView)findViewById(R.id.TextView01); 设置TextView标签内容 Stringstr_2="欢迎来到Android的TextView世界..."; mTextView01.setText(str_2); 设置文本超级链接 <TextView android:id="@+id/TextView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autoLink="all" android:text="请访问Android开发者: http://developer.android.com/index.html"> </TextView> android.graphics.Color实践----Color颜色变幻 android.graphics.Color包含颜色值 Color.BLACK Color.BLUE Color.CYAN Color.DKGRAY Color.GRAY Color.GREEN Color.LTGRAY Color.MAGENTA Color.RED Color.TRANSPARENT Color.WHITE Color.YELLOW黑色 蓝色 青绿色 灰黑色 灰色 绿色 浅灰色 红紫色 红色 透明 白色 黄色 编程实现颜色变幻 新建工程 修改mainActivity.java文件,添加12个TextView对象变量,一个LinearLayout对象变量、一个WC整数变量、一个LinearLayout.LayoutParams变量。 packagezyf.ManyColorME; /*导入要使用的包*/ importandroid.app.Activity; importandroid.graphics.Color; importandroid.os.Bundle; importandroid.widget.LinearLayout; importandroid.widget.TextView; publicclassManyColorMEextendsActivity{ /**Calledwhentheactivityisfirstcreated.*/ /*定义使用的对象*/ privateLinearLayoutmyLayout; privateLinearLayout.LayoutParamslayoutP; privateintWC=LinearLayout.LayoutParams.WRAP_CONTENT; privateTextViewblack_TV,blue_TV,cyan_TV,dkgray_TV, gray_TV,green_TV,ltgray_TV,magenta_TV,red_TV, transparent_TV,white_TV,yellow_TV; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); /*实例化一个LinearLayout布局对象*/ myLayout=newLinearLayout(this); /*设置LinearLayout的布局为垂直布局*/ myLayout.setOrientation(LinearLayout.VERTICAL); /*设置LinearLayout布局背景图片*/