应用篇1.3 后台登陆界面审计

一、后台登陆界面图:

各种准备工作完毕后,对于这款日程管理类的软件,首先设计一个后台登陆功能。可以通过密码保护自己的日程隐私。

1、初次登陆界面如图1.1所示。

2、如果已经设置了密码,登陆界面如图1.2所示。

二、登陆界面代码

初次登陆:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/PasswordRoot"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1.0"android:background="@drawable/default_bg"android:orientation="vertical" ><RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginLeft="15.0px"android:layout_marginRight="15.0px"android:layout_marginTop="62.0px"android:paddingBottom="10.0px"android:paddingTop="21.0px" ><EditTextandroid:id="@+id/pwd"android:layout_width="fill_parent"android:layout_height="wrap_content"android:background="@drawable/password_edit_login"android:hint="@string/input_password"android:inputType="textPassword"android:maxLength="10"android:paddingLeft="40.0sp"android:saveEnabled="true" /><EditTextandroid:id="@+id/pwd_repeat"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@+id/pwd"android:background="@drawable/password_edit_login"android:hint="@string/repeat_password"android:inputType="textPassword"android:maxLength="10"android:paddingLeft="40.0sp"android:saveEnabled="true" /><Buttonandroid:id="@+id/ok"android:layout_width="130.0px"android:layout_height="42.0px"android:layout_alignParentRight="true"android:layout_below="@+id/pwd_repeat"android:layout_marginRight="12.0dip"android:layout_marginTop="7.0px"android:text="@string/ok" /></RelativeLayout></LinearLayout></LinearLayout>

设置完密码后登陆:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/loginRoot"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1.0"android:background="@drawable/default_bg"android:orientation="vertical" ><RelativeLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginLeft="15.0px"android:layout_marginRight="15.0px"android:layout_marginTop="62.0px"android:paddingBottom="10.0px"android:paddingTop="21.0px" ><EditTextandroid:id="@+id/login_pwd"android:layout_width="fill_parent"android:layout_height="wrap_content"android:background="@drawable/password_edit_login"android:hint="@string/input_password"android:inputType="textPassword"android:maxLength="10"android:paddingLeft="40.0sp"android:saveEnabled="true" /><Buttonandroid:id="@+id/login"android:layout_width="130.0px"android:layout_height="42.0px"android:layout_alignParentRight="true"android:layout_below="@+id/login_pwd"android:layout_marginRight="12.0dip"android:layout_marginTop="7.0px"android:text="@string/login" /></RelativeLayout></LinearLayout></LinearLayout>

业务逻辑代码:

/** Copyright (c) 2013 Solidwang. All Rights Reserved*/
package com.solidwang.something.activity;
import com.solidwang.something.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;import com.solidwang.something.db.DBUtil;
/*** <p>*     Description: 登陆界面* </p>* @author solidwang* @version 1.0* @Date 2013-4-24*/
public class Login extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);DBUtil db = new DBUtil(this);String password = db.getPwd();//第一次登陆需要设置密码if("".equals(password)) {Intent intent = new Intent(Login.this, PasswordManager.class);startActivity(intent);finish();return;}//如果已经设置密码,进入登陆界面setContentView(R.layout.login);}
}
/** Copyright (c) 2013 Sohu. All Rights Reserved*/
package com.solidwang.something.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;import com.solidwang.something.R;
import com.solidwang.something.db.DBUtil;/*** <p>*     Description: 密码管理界面* </p>* @author solidwang* @version 1.0* @Date 2013-4-24*/
public class PasswordManager extends Activity {//密码输入框private EditText pwd, pwd_repeat;private Button ok;private DBUtil db;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);db = new DBUtil(this);setContentView(R.layout.password_manager);pwd = (EditText)findViewById(R.id.pwd);pwd_repeat = (EditText)findViewById(R.id.pwd_repeat);ok = (Button)findViewById(R.id.ok);ok.setOnClickListener(new LoginListener());}class LoginListener implements OnClickListener {@Overridepublic void onClick(View v) {String password1 = pwd.getText().toString();String password2 = pwd_repeat.getText().toString();if("".equals(password1) || "".equals(password2) || password1==null || password2==null) {Toast.makeText(PasswordManager.this, R.string.password_is_null, Toast.LENGTH_SHORT).show();} else {if(password1.equals(password2)) {if("".equals(db.getPwd())) {db.insertPwd(password1);} else {db.updatePwd(password1);}} else {Toast.makeText(PasswordManager.this, R.string.password_is_different, Toast.LENGTH_SHORT).show();}}}}
}

数据库操作源码:

/** Copyright (c) 2013 Solidwang. All Rights Reserved*/
package com.solidwang.something.db;import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;/*** <p>*     Description: 数据库操作工具类* </p>* @author solidwang* @version 1.0* @Date 2013-4-23*/
public class DBUtil extends SQLiteOpenHelper{//数据库private static final String DATABASE_NAME = "something_db";private static final Integer DATABASE_VERSION = 1;//登陆表名及字段private static final String TABLE_LOGIN = "login";private static final String LOGIN_USER = "admin";private static final String LOGIN_PWD = "password";//日程表名及字段private static final String TABLE_SCHEDULE = "schedule";private static final String SCHEDULE_ID = "id";private static final String SCHEDULE_TITLE = "title";private static final String SCHEDULE_CONTENT = "content";private static final String SCHEDULE_CREATETIME = "createtime";//闹钟表名及字段private static final String TABLE_CLOCK = "clock";private static final String CLOCK_ID = "id";private static final String CLOCK_ISOPEN = "isopen";private static final String CLOCK_DATE = "date";private static final String CLOCK_TIME = "time";private static final String CLOCK_RINGS = "rings";private static final String CLOCK_URI = "uri";public DBUtil(Context context) {super(context, DATABASE_NAME, null, DATABASE_VERSION);}@Overridepublic void onCreate(SQLiteDatabase db) {//新建login表String sql = "create table "+TABLE_LOGIN+" ("+LOGIN_USER+" text, "+LOGIN_PWD+" text)";db.execSQL(sql);//新建schedule表sql = "create table "+TABLE_SCHEDULE+" ("+SCHEDULE_ID+" integer primary key autoincrement, "+SCHEDULE_TITLE+" text, "+SCHEDULE_CONTENT+" text, "+SCHEDULE_CREATETIME+" text )";db.execSQL(sql);//新建clock表sql = "create table "+TABLE_CLOCK+" ("+CLOCK_ID+" integer primary key, "+CLOCK_ISOPEN+" text, "+CLOCK_DATE+" text, "+CLOCK_TIME+" text, "+CLOCK_RINGS+" text, " +CLOCK_URI+" text )";db.execSQL(sql);}@Overridepublic void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {String sql = "drop table if exists "+TABLE_LOGIN;db.execSQL(sql);sql = "drop table if exists "+TABLE_SCHEDULE;db.execSQL(sql);sql = "drop table if exists "+TABLE_CLOCK;db.execSQL(sql);}/** 返回密码*/public String getPwd() {SQLiteDatabase sld = this.getReadableDatabase();String where = LOGIN_USER+"=?";String[] whereValues = {LOGIN_USER}; Cursor cursor = sld.query(TABLE_LOGIN, null, where, whereValues, null, null, null);if(cursor.moveToFirst()) {return cursor.getString(cursor.getColumnIndex(LOGIN_PWD));} else {return "";}}/** 保存密码*/public long insertPwd(String password){SQLiteDatabase db = this.getWritableDatabase();ContentValues cv = new ContentValues();cv.put(LOGIN_USER, LOGIN_USER);cv.put(LOGIN_PWD, password);return db.insert(TABLE_LOGIN, null, cv);}/** 修改密码*/public int updatePwd(String password){SQLiteDatabase db = this.getWritableDatabase();String where = LOGIN_USER+"=?";String[] whereValues = {LOGIN_USER};ContentValues cv = new ContentValues();cv.put(LOGIN_PWD, password);return db.update(TABLE_LOGIN, cv, where, whereValues);}
}

应用篇1.3 后台登陆界面设计相关推荐

  1. android布局基础及范例:QQ登陆界面设计

    使用android手机的用户想必都有android手机QQ客户端吧,我们是不是觉得QQ登陆界面非常漂亮美观而且具有亲和力?我们是不是也想作出像 QQ那样美观的界面?有的人肯定会问,做UI那不是美工人员 ...

  2. wp-login.php 404页面,wordpress隐藏后台登陆界面,自动跳转首页或404

    原标题:wordpress隐藏后台登陆界面,自动跳转首页或404 我们用wordpress程序安装建站后发现所有人的网站后台都是自己域名/wp-admin,这样是否存在安全隐患?那么我们如何来修改或是 ...

  3. 织梦后台登陆界面如何修改

    遇到问题: 织梦后台默认的登录界面含有广告,如果你有好的后台登录界面想要替换处理,该如何操作? 解决办法: 文章参考:织梦后台登陆界面的更改 织梦后台的文件都在dede文件里面,如果自己修改过了,就是 ...

  4. Android学习之登陆界面设计(一)前后期准备以及相关配置

    Android学习之登陆界面设计(一)前后期准备以及相关配置 前言 成品 成品样式 成品特点 工具 系统配置 手机配置 Android Studio 3.6.3 SDK 图片来源 矢量图标库 Back ...

  5. Android学习之登陆界面设计(二)基本界面设计

    Android学习之登陆界面设计(二)基本界面设计 前提 绘图样式 - drawable bg_login_btn_submit.xml bg_login_panel_slide.xml bg_log ...

  6. 高端大气的Emlog后台登陆界面模板

    介绍: 这款后台登陆界面板子是本屌花一个上午(也就半个小时)仿的一个WordPress后台,江南安全社区的后台登陆界面,我看着挺不错的,就特么给扒下来了. 现在分享出来咯~哈哈哈哈~不用谢~~~(不喜 ...

  7. QML与C++交互:登陆界面设计

    环境: 主机:WIN7 开发环境:Qt5.2.1 说明: QML设计前台界面,C++后台负责逻辑 效果图: 源代码: 前台qml文件 login.qml [javascript] view plain ...

  8. Easyui后台管理界面设计

    1 Easyui 后台管理界面登陆设计 @{Layout = null; }<!DOCTYPE html><html> <head><meta name=&q ...

  9. pyqt界面屏幕分辨率自适应_后台系统界面设计踩过的那些坑

    源起 由于之前曾经在后台系统开发公司工作过的缘故,所以有些后台管理系统界面的产出.后来虽然从那家公司离职,但也接到过一些后台界面设计和优化的项目,前前后后也快十来个了. 这里想分享下一些关于后台界面设 ...

最新文章

  1. PLSQL_海量数据处理系列3_索引
  2. numpy学习(2):数组创建方式
  3. linux调度全景指南
  4. 【基于XML方式】Spring整合Kafka
  5. 第2小节,深入剖析gym环境构建
  6. 遇上DG挖矿病毒的处理记录
  7. spirng底层实现原理
  8. php 多维数组怎么表达,php 对多维数组的操作,该怎么解决
  9. 【影像学基本知识】Slice gap and slice thickness and cross-talk
  10. 企业架构 | TOGAF内容框架
  11. native内存泄漏分析
  12. api质量等级_API质量等级与机油选用指引
  13. html中三角函数表示什么,三角函数的化一公式
  14. 深入理解操作系统——datalab-handout
  15. 阿里云账号个人实名认证教程
  16. usart hmi(串口屏)介绍
  17. logo设计灵感的创意网站
  18. 项目经理如何成功地分配任务?| 每天成就更大成功
  19. 解决Android调试微信页面,chrome的inspect弹出空白
  20. Tensorflow+gensim实现文章自动审核功能

热门文章

  1. openfire 的源代码分析 clint-to-server
  2. 实验2 SQL 查询语句
  3. 大数据与云计算的未来趋势
  4. Android 组件化面试必备,android输入法开发源码
  5. 虚幻4中常用按键和快捷键
  6. DanDan日语学堂 入门篇01 五十音图(上)
  7. mx570、3050和2050选哪个 mx570、RTX3050和RTX2050差距
  8. 中级电工电拖实训考核装置
  9. 浅谈UTF-8、GBK、gb2312
  10. RUST笔记_特性Box和闭包Box