代码改变世界

随笔分类 -  Android

android中的TabHost(选项卡)的使用

2012-05-17 17:50 by Rollen Holt, 3983 阅读, 收藏, 编辑
摘要: 效果图如下: 其中main.xml代码如下: <?xml version="1.0" encoding="utf-8"?><TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="... 阅读全文

android中DatePicker和TimePicker的使用

2012-05-17 16:32 by Rollen Holt, 4482 阅读, 收藏, 编辑
摘要: 先来看看效果图吧: 下面来贴出代码吧,其中main.xml代码为: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android... 阅读全文

android中的Spinner的使用

2012-05-17 16:03 by Rollen Holt, 2399 阅读, 收藏, 编辑
摘要: 先来最终的效果吧: 我们的main.xml文件内容为: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layou... 阅读全文

Android中的AutoCompleteTextView的使用

2012-05-17 15:50 by Rollen Holt, 27111 阅读, 收藏, 编辑
摘要: 最终的效果如下: main.xml代码如下: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_hei... 阅读全文

Android写的一个设置图片查看器,可以调整透明度

2012-05-17 15:37 by Rollen Holt, 5412 阅读, 收藏, 编辑
摘要: 先来看看效果吧:main.xml代码如下: 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" 5 android:orientation=" 阅读全文

Android中的Chronometer

2012-05-17 13:16 by Rollen Holt, 4358 阅读, 收藏, 编辑
摘要: 这个例子演示的是点击按钮之后,计数增长,到20后自动停止其中main.xml代码为: 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" 5 andro 阅读全文

Android中的DigitalClock和AnalogClock

2012-05-17 13:00 by Rollen Holt, 620 阅读, 收藏, 编辑
摘要: 先来看看效果图吧:main.xml代码如下: 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" 5 android:orientation=" 阅读全文

android中ToggleButton的使用

2012-05-17 12:44 by Rollen Holt, 12714 阅读, 收藏, 编辑
摘要: 这个小例子主要用来演示ToggleButton的基本使用。效果大致是一开始界面是垂直布局的,当点击ToggleButton按钮的时候,布局变为水平方向的大致的代码贴一下吧,其中main.xml代码如下:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" andr 阅读全文

android中的单选和多选框

2012-05-17 12:15 by Rollen Holt, 25805 阅读, 收藏, 编辑
摘要: 先展示一下效果图大致代码如下: 1 <?xml version="1.0" encoding="utf-8"?> 2 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" > 5 6 <TableRow 7 android:id= 阅读全文

android中的按钮,图形按钮,带文字的图片按钮

2012-05-17 11:51 by Rollen Holt, 23163 阅读, 收藏, 编辑
摘要: 先来看看效果图吧:效果就是这么简单,其中第一行的2个算是默认的吧,第二行的2个按钮当鼠标点击的时候图片发送变化。其中main.xml大致代码如下:<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_ 阅读全文

android搞的一个登录界面

2012-05-17 11:20 by Rollen Holt, 5497 阅读, 收藏, 编辑
摘要: 还是先上传图片把。设计的很丑,脏了大家的眼球了。实现的基本需求,没有详细的设计高度,宽度什么的。还没添加验证功能,待完善。代码如下:<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent 阅读全文

android被逼学习布局管理器

2012-05-16 21:08 by Rollen Holt, 728 阅读, 收藏, 编辑
摘要: 先来说说android里面的线性布局吧。线性布局用LinearLayout代表,他不仅可以水平的线性布局,也可以在垂直方向上进行线性布局,使用 android:orientation="vertical" 来进行设置。 不过LinearLayout的一个问题是当组件在水平方向上无法全部显示的时候,他不会自动换行,也就说后面的不能显示出来了。这种情况需要注意一下。 有2个常用的属性: ... 阅读全文

Android被逼学习例子2

2012-05-16 20:32 by Rollen Holt, 1361 阅读, 收藏, 编辑
摘要: 接下来的这个小例子演示当手指在触摸屏上拖动的时候,一个红色的小球更随手指进行移动。不过这个例子大致演示了一下自定义UI组件。 先来看看效果吧: 代码大致如下: AndroidDemoActivity.java package Android.Demo;import android.app.Activity;import android.os.Bundle;import andro... 阅读全文

Android被逼学习小例子1

2012-05-16 20:11 by Rollen Holt, 3193 阅读, 收藏, 编辑
摘要: 这个程序的功能就是当点击图片的时候,就会自动切换到下一个图片。对,就是这么简单的一个功能,高手请不要鄙视。主要的代码如下:HelloWorldActivity.java代码为:package hello.com;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.ViewGroup;import android.widget.Button;import android.w 阅读全文

Android基础概念

2012-05-16 19:08 by Rollen Holt, 1399 阅读, 收藏, 编辑
摘要: 最近为了应付老外的Android作业,所以不得不开始学习一下Android。在这里不得不吐槽一下学校,悄悄的将我们选的嵌入式换成Android,而不通知我们。 先简单的介绍一下Android中UI组件的一些通用属性吧: android:id 是指定控件的位置标识,在java程序中可以通过findViewById(“id”)来获取指定的android界面组件。 android:layout_width和android:layout_height用来指定界面组件的宽度和高度,如果这个属性值设置为fill_parent的话,也就是说明这个组件和其父组件具有相同的宽度,如果属性值设置为warp_co. 阅读全文