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

Android开发:利用Shared Preferences实现用户本地登录

[日期:2012-08-04] 来源:Linux社区  作者:ziyang1993 [字体:大 中 小]

上面最基本的一些含义已经注释了,记住一点就是这点:

//这里注意要先消去对话框 再finish掉Activity 否则 有bug

if (isFirst)

{ setPrefernAlertDialog.dismiss();

MainActivity.this.finish(); }

下面是show_password_dialog.xml:

  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.     <EditText   
  8.      android:id="@+id/username"  
  9.      android:layout_width="fill_parent"  
  10.      android:layout_height="wrap_content"     
  11.      android:hint="请输入用户名 :"     
  12.         />  
  13.     <EditText   
  14.      android:id="@+id/password"     
  15.      android:layout_width="fill_parent"  
  16.      android:layout_height="wrap_content"  
  17.      android:password="true"     
  18.      android:hint="请输入用户密码:"     
  19.         />  
  20. <LinearLayout   
  21.     android:orientation="horizontal"  
  22.     android:layout_width="fill_parent"  
  23.     android:layout_height="wrap_content"  
  24.     >  
  25.     <Button   
  26.     android:id="@+id/ok"      
  27.     android:layout_width="wrap_content"  
  28.     android:layout_height="wrap_content"  
  29.     android:text="@string/ok"   
  30.     android:layout_weight="1"  
  31.     android:textSize="20sp"  
  32.     android:textColor="@color/purple"  
  33.         />  
  34.         <Button   
  35.     android:id="@+id/cancle"      
  36.     android:layout_width="wrap_content"  
  37.     android:layout_height="wrap_content"  
  38.     android:text="@string/cancle"   
  39.     android:layout_weight="1"  
  40.     android:textSize="20sp"    
  41.     android:textColor="@color/purple"  
  42.  />  
  43. </LinearLayout>  
  44. </LinearLayout>  
linux
相关资讯       Android开发基础教程 
本文评论   查看全部评论 (1)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 1 楼
* 匿名 发表于 2013/11/22 19:32:20
看着不错。。