Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Android中Activity的切换

以登录为例,假设有一个界面为登录界面,另一个为登录成功后跳转的页面
----------登陆界面----------------                                                -------------登陆成功后跳转的页面--------------用户名的输入框(editText组件)                                             欢迎你,XXX用户密码的输入框(editText组件)
登录按钮(button组件)------------------------------------                                                 -------------------------------------------------------页面的布局代码如下:----------登陆界面----------------    
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7. <TextView    
  8.     android:layout_width="fill_parent"   
  9.     android:layout_height="wrap_content"   
  10.     android:text="@string/logintitle"  
  11.     android:textSize="24sp"  
  12.     />  
  13.     <editText      
  14.         android:id="@+id/username"    
  15.         android:layout_width="fill_parent"  
  16.         android:layout_height="match_parent"  
  17.         android:hint="@string/nametip"    请输入用户名  
  18.     />  
  19.     <editText      
  20.         android:id="@+id/password"  
  21.         android:layout_width="fill_parent"  
  22.         android:layout_height="match_parent"  
  23.         android:hint="@string/pwdtip"    请输入密码    
  24.         android:password="true"    
  25.     />  
  26.     <Button  
  27.         android:id="@+id/loginbutton"  
  28.         android:layout_width="fill_parent"  
  29.         android:layout_height="match_parent"  
  30.         android:text="@string/loginbutton"      
  31.     />  
  32.       
  33. </LinearLayout>  
-------------登陆成功后跳转的页面--------------
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7. <TextView    
  8.     android:id="@+id/result"  
  9.     android:layout_width="fill_parent"   
  10.     android:layout_height="wrap_content"   
  11.     android:text="@string/result"  
  12.     android:textSize="24sp"  
  13.     />  
  14.     
  15.     <Button  
  16.         android:id="@+id/loginbutton"  
  17.         android:layout_width="fill_parent"  
  18.         android:layout_height="match_parent"  
  19.         android:text="@string/jumpbutton"  跳转    
  20.     />  
  21.       
  22. </LinearLayout>