Android移动终端设计实验三+Intent与Activity实验
实验3:Intent与Activity实验
一、 实验目的 本次实验的目的是了解Intent的Action、Catalog、Data等属性的用法,掌握Intent的启动机制以及利用Intent意图在应用程序Activity间启动、停止和传输数据。 |
二、 实验环境 Windows7 Eclipse MARS.2 AVD虚拟机 |
三、实验内容及结果 题目1在实验1建立的登录界面基础上,实现:点击登录按钮后,显示登录成功界面; 题目2在实验1建立的登录界面基础上, 实现:点击登录按钮后,显示登录成功界面,并显示登录用户名,即:“欢迎XXX使用本系统字样”;
1. 无参数传递 代码实现:
Activity_main.xml <LinearLayoutxmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="欢迎使用登录系统 -by庞振男" ></TextView>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/user" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="用户名:"/> <EditText android:id="@+id/username" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="input username"
></EditText> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/pass" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="密码:"/> <EditText android:id="@+id/password" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="input password" android:inputType="textPassword" ></EditText> </LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/login" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="登录" ></Button> <Button android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="取消" ></Button> </LinearLayout>
<TextView android:id="@+id/show" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="tips:"/> </LinearLayout>
MainActivity.java
|