可记住用户名和密码的登录界面
来源:互联网 发布:linux代码学习 编辑:程序博客网 时间:2024/05/16 19:16
<?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"
android:background="@drawable/14-111223154547-50"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<TextView
android:id="@+id/tvUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/tvName"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvUsername"
android:layout_below="@+id/tvUsername"
android:background="@android:drawable/edit_text"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/tvPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etUsername"
android:layout_below="@+id/etUsername"
android:text="@string/tvPassword"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvPassword"
android:layout_below="@+id/tvPassword"
android:layout_marginTop="16dp"
android:background="@android:drawable/edit_text"
android:ems="10"
android:inputType="textPassword" />
<CheckBox
android:id="@+id/rem_pw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etPassword"
android:layout_below="@+id/etPassword"
android:text="记住密码" />
<CheckBox
android:id="@+id/auto_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/rem_pw"
android:layout_alignBottom="@+id/rem_pw"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@+id/rem_pw"
android:text="自动登录" />
<Button
android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/auto_login"
android:layout_below="@+id/auto_login"
android:layout_marginLeft="50dp"
android:layout_marginTop="20dp"
android:background="#999966"
android:text="@string/btnLogin" />
</RelativeLayout>
LoginActivity.java
package com.example.minitwittersimulate;
import android.os.Bundle;
import android.app.Activity;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
public class LoginActivity extends Activity {
private EditText userName, password;
private CheckBox rem_pw, auto_login;
private Button btn_login;
private ImageButton btnQuit;
private String userNameValue,passwordValue;
private SharedPreferences sp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MiniTwitterSimulate</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="tvName">用户名</string>
<string name="tvPassword">密码</string>
<string name="btnLogin">登录</string>
<string name="tvRegister">没有帐号? <a href="#" mce_href="#">注册</a></string>
<string name="tvText">欢迎登陆本系统。</string>
</resources>
- 可记住用户名和密码的登录界面
- 可记住用户名和密码的登录界面
- 登录界面—记住用户名和密码
- 登录时记住用户名和密码的Cookie实现方法
- 登录时记住用户名和密码的Cookie实现方法
- 登录中用于记住用户名和密码的方法
- 登录时记住用户名和密码的Cookie实现方法
- 登录记住用户名密码
- Javascrip 登录记住用户名和密码
- 登录界面如何实现记住用户名和密码 且实现自动登录
- 可记住用户名密码的登陆界面(基于对SharedPreferences的应用)
- Android实现登录界面记住用户名与密码
- Android 记住密码和自动登录界面的实现
- 记住密码和自动登录界面的实现
- Android 记住密码和自动登录界面的实现
- Android 记住密码和自动登录界面的实现
- Android 记住密码和自动登录界面的实现
- 登录界面 记住密码
- 用URL浏览图片
- 能量英语(四) 之 “信念”
- leetcode 226 :Invert Binary Tree
- CFStringTransform的使用 :汉字转拼音、全角转半角等
- 用wireshark解析应用层存储包
- 可记住用户名和密码的登录界面
- 详细解说STL string
- 背景音乐
- Oracle 存储过程创建和执行入门实例
- C++ Primer学习笔记(7)——指针形参和引用形参的比较
- 关于SoftReference,WeakReference的简单了解
- eclipse中maven插件上传项目jar包到私服
- Windows显示驱动中读取EDID
- Android ListView使用详解