1 实验名称
保存密码和自动登录
2 实验目的
掌握利用SharedPreference实现记住密码和自动登录功能。
3 实验源代码
布局文件代码:
(1)activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TableRow>
<TextView
android:text="账号"
android:layout_marginRight="10dp"
android:textSize="18sp"
/>
<EditText
android:id="@+id/userNameET"
android:hint="请输入账号"
/>
</TableRow>
<TableRow>
<TextView
android:text="密码"
android:layout_marginRight="10dp"
android:textSize="18sp"
/>
<EditText
android:id="@+id/passWordET"
android:hint="请输入密码"
/>
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/savePwdCB"
android:text="记住密码"
/>
<CheckBox
android:id="@+id/autoLoginCB"
android:text="自动登录"
/>
<But

最低0.47元/天 解锁文章
1095

被折叠的 条评论
为什么被折叠?



