你好,游客 登录 注册 搜索
背景:
阅读新闻

Android中Activity的切换

[日期:2011-07-31] 来源:Linux社区  作者:wangchenggong1988 [字体:大 中 小]

以登录为例,假设有一个界面为登录界面,另一个为登录成功后跳转的页面


----------登陆界面----------------                                                -------------登陆成功后跳转的页面--------------

用户名的输入框(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>  
linux
相关资讯       Android教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款