运行效果图
实例程序讲解
在打开登陆界面时,程序会自动填写上次您输入正确的用户名和密码。小编本次为大家提供的是用SharePreferences对象来实现此功能的。
activity_main.xml
<span style="font-size:18px;"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/loginbg"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<include layout="@layout/login_top"/>
<include layout="@layout/login_bottom"/>"
</LinearLayout></span>
<strong>login_bottom.xml</strong>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvRegist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="21dp"
android:layout_marginTop="18dp"
android:text="@string/tvRegister"
android:autoLink="all"
android:textColorLink="#FF0066CC" />
<ImageView
android:id